################################################################################################### # # Multi-Stage Docker build using Ubunut-Buster Python 3.9 slim # ################################################################################################### # Define build arguments ARG CODE_DIR="/app" ARG UNAME=dicom ARG UID=1010 ARG GID=1010 FROM python:3.9-slim as build-image # Install aws-lambda-cpp build dependencies RUN apt-get update && \ apt-get install -y \ g++ \ make \ cmake \ unzip \ libcurl4-openssl-dev # Include Global Args in this stage ARG CODE_DIR # Create app directory RUN mkdir -p ${CODE_DIR} # Copy code to directory COPY src/ ${CODE_DIR} # Install the aws-lambda-python-runtime-interface-client RUN pip install \ --target ${CODE_DIR} \ awslambdaric # Install libraries from requirements.txt file RUN pip install \ --target ${CODE_DIR} \ -r ${CODE_DIR}/requirements.txt # Multi-stage build: FROM python:3.9-slim # Include Global Args in this stage ARG CODE_DIR UID GID UNAME # Set working directory to function app directory WORKDIR ${CODE_DIR} # Create Group and User to run code RUN groupadd -g $GID -o $UNAME && useradd -m -u $UID -g $GID -o -s /bin/sh $UNAME USER $UNAME:$UNAME # Copy code and dependencies from previous stage COPY --from=build-image ${CODE_DIR} ${CODE_DIR} # Custom ENTRYPOINT to select Lambda or Batch Inovation ENTRYPOINT [ "./start.sh" ] # CMD pass parameter to start.sh script (Lambda Configuration by default) CMD [ "app.lambda_handler" ]