|
| 1 | +# Note: |
| 2 | +# Within docker, this container runs as root as no user is specified. |
| 3 | +# Due to the nature of the lambda function, this is acceptable as Lambda defines the default user |
| 4 | +# to have the least-privilege permissions rather than the root user. |
| 5 | + |
| 6 | +# Therefore we can ignore the linting error for this Dockerfile |
| 7 | +# as it is not a security risk for this specific use case. |
| 8 | + |
| 9 | +# Ignored in .trivyignore also. |
| 10 | +#kics-scan disable=fd54f200-402c-4333-a5a4-36ef6709af2f |
| 11 | +#checkov:skip=CKV_DOCKER_3:Lambda makes default user lowest privilege |
| 12 | + |
| 13 | +FROM public.ecr.aws/lambda/python:3.12 |
| 14 | + |
| 15 | +# Install git using dnf (https://docs.aws.amazon.com/lambda/latest/dg/python-image.html#python-image-base) |
| 16 | +# For python 3.12, dnf replaces yum for package management |
| 17 | +RUN dnf install -y git-2.40.1 && dnf clean all |
| 18 | + |
| 19 | +# Copy the poetry.lock and pyproject.toml files |
| 20 | +COPY pyproject.toml poetry.lock ${LAMBDA_TASK_ROOT}/ |
| 21 | + |
| 22 | +# Install the dependencies |
| 23 | +WORKDIR ${LAMBDA_TASK_ROOT} |
| 24 | +RUN pip install --no-cache-dir poetry==1.5.0 &&\ |
| 25 | + poetry config virtualenvs.create false &&\ |
| 26 | + poetry install --only main |
| 27 | + |
| 28 | +# Copy config folder |
| 29 | +COPY config ${LAMBDA_TASK_ROOT}/config |
| 30 | + |
| 31 | +# Copy function code |
| 32 | +COPY src/main.py src/logger.py ${LAMBDA_TASK_ROOT}/src/ |
| 33 | + |
| 34 | +HEALTHCHECK NONE |
| 35 | + |
| 36 | +# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) |
| 37 | +CMD [ "src.main.handler" ] |
0 commit comments