I use Codebuild to deploy ecr image for lambda.
CodeCommit Repo:
CodeBuild's buildspec.yml:
version: 0.2
env:
variables:
repo_uri: "123456789100.dkr.ecr.ap-northeast-2.amazonaws.com/my-ecr-repo:latest"
ecr_repo: "my-ecr-repo"
region: "ap-northeast-2"
phases:
build:
commands:
- aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 12345678900.dkr.ecr.ap-northeast-2.amazonaws.com
- docker build -t ${ecr_repo} . --build-arg REGION=${region}
- docker tag ${ecr_repo} ${repo_uri}
- docker push ${repo_uri}
Dockerfile:
FROM public.ecr.aws/lambda/python:3.9
COPY main/app.py ${LAMBDA_TASK_ROOT}
RUN pip3 install pandas
RUN pip3 install pymysql
ENV PYTHONUNBUFFERED=TRUE
CMD [ "app.lambda_handler" ]
When i start the build, it takes only 3 minutes, which is about 8 times less than if i uploaded an ecr image without using CodeBuild.
Also, When I use this ecr image for lambda, below error is shown:
RequestId: 614fa6a4-2dad-4c5a-8527-8d060b80f86d Error: fork/exec /lambda-entrypoint.sh: exec format error
Runtime.InvalidEntrypoint
NOTE. Already seen that there is a function called lambda_handler inside the app.py file.
NOTE. If there's anything else that I can do to fix this, please comment.
