ARG RUNTIME_VERSION ARG DISTRO_VERSION # Stage 1 - build function and dependencies FROM public.ecr.aws/docker/library/python:${RUNTIME_VERSION}-${DISTRO_VERSION} AS python-debian-builder # Install aws-lambda-cpp build dependencies RUN apt-get update && \ apt-get install -y \ g++ \ make \ cmake \ libcurl4-openssl-dev # Include global args in this stage of the build ARG RIC_BUILD_DIR="/home/build/" # Create function directory RUN mkdir -p ${RIC_BUILD_DIR} # Copy function code and Runtime Interface Client .tgz WORKDIR ${RIC_BUILD_DIR} COPY . . RUN make init build test && \ mv ./dist/awslambdaric-*.tar.gz ./dist/awslambdaric-test.tar.gz # Include global args in this stage of the build ARG FUNCTION_DIR="/home/app/" # Create function directory RUN mkdir -p ${FUNCTION_DIR} # Copy function code COPY tests/integration/test-handlers/echo/* ${FUNCTION_DIR} # Copy Runtime Interface Client .tgz RUN cp ./dist/awslambdaric-test.tar.gz ${FUNCTION_DIR}/awslambdaric-test.tar.gz # Install the function's dependencies WORKDIR ${FUNCTION_DIR} RUN pip install \ awslambdaric-test.tar.gz \ --target ${FUNCTION_DIR} && \ rm awslambdaric-test.tar.gz # Stage 2 - final runtime interface client image # Grab a fresh slim copy of the Python image FROM public.ecr.aws/docker/library/python:${RUNTIME_VERSION}-slim-${DISTRO_VERSION} # Include global arg in this stage of the build ARG FUNCTION_DIR="/home/app/" # copy the lambda function code COPY --from=python-debian-builder ${FUNCTION_DIR} ${FUNCTION_DIR} # Set working directory to function root directory WORKDIR ${FUNCTION_DIR} ENTRYPOINT ["/usr/local/bin/python", "-m", "awslambdaric"] CMD ["app.handler"]