-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from dag-hammarskjold-library/docker-and-lambda
dockerize, push to ECR, and update lambda
- Loading branch information
Showing
7 changed files
with
84 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build and push container to ECR and Lambda | ||
on: | ||
release: | ||
types: [ released ] | ||
|
||
jobs: | ||
deploy: | ||
name: Build Docker and Deploy Lambda | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build, tag, and push the image to ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ secrets.REPO_NAME }} | ||
IMAGE_TAG: latest | ||
run: | | ||
cd ./aws-lambda | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | ||
echo "Pushing image to ECR..." | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Deploy image to Lambda | ||
id: deploy-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ secrets.REPO_NAME }} | ||
IMAGE_TAG: latest | ||
run: | | ||
aws lambda update-function-code \ | ||
--function-name dlx-dl-lambda \ | ||
--image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
- name: Update EventBridge Rules | ||
id: update-rules | ||
run: | | ||
aws events put-rule \ | ||
--name dlx-dl-lambda-bib \ | ||
--schedule-expression "rate(10 minutes)" | ||
aws events put-targets \ | ||
--rule dlx-dl-lambda-bib \ | ||
--targets '[{"Id":"1","Arn":"${{ secrets.FUNCTION_ARN }}","Input":"{\"source\":\"dlx-dl-lambda\",\"type\":\"bib\",\"modified_within\":86400,\"queue\":true}"}]' | ||
aws events put-rule \ | ||
--name dlx-dl-lambda-auth \ | ||
--schedule-expression "rate(10 minutes)" | ||
aws events put-targets \ | ||
--rule dlx-dl-lambda-auth \ | ||
--targets '[{"Id":"1","Arn":"${{ secrets.FUNCTION_ARN }}","Input":"{\"source\":\"dlx-dl-lambda\",\"type\":\"auth\",\"modified_within\":86400,\"queue\":true}"}]' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM public.ecr.aws/lambda/python:3.11 | ||
|
||
# Copy requirements.txt | ||
COPY requirements.txt ${LAMBDA_TASK_ROOT} | ||
|
||
# Install git | ||
RUN yum install -y git-all | ||
|
||
# Install the specified packages | ||
RUN pip install -r requirements.txt | ||
|
||
# Copy function code | ||
COPY service.py ${LAMBDA_TASK_ROOT} | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "service.handler" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
../. # installs dlx-dl from the directory above | ||
python-lambda @ git+https://github.com/nficano/python-lambda@2f9f17a5c5993e65ee2b61d06f29ed5a6689d337 | ||
dlx-dl @ git+https://github.com/dag-hammarskjold-library/dlx-dl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
setup( | ||
name = 'dlx_dl', | ||
version = '1.2.3', | ||
version = '1.2.4', | ||
url = 'http://github.com/dag-hammarskjold-library/dlx-dl', | ||
author = 'United Nations Dag Hammarskjöld Library', | ||
author_email = '[email protected]', | ||
|