Skip to content

Commit

Permalink
UML-3210 Use Python slim for building lambda (#2490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Ainsworth authored Jan 9, 2024
1 parent 45207d6 commit f501d98
Showing 1 changed file with 7 additions and 35 deletions.
42 changes: 7 additions & 35 deletions lambda-functions/upload-statistics/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,27 @@
# Define function directory
ARG FUNCTION_DIR="/function"

FROM python:3.11.7-alpine3.18 AS python-alpine
RUN apk add --no-cache \
libstdc++

# Upgrade insecure packages
RUN apk update && apk upgrade expat krb5-libs libcrypto1.1 libssl1.1 libcom_err ncurses busybox openssl
RUN pip install setuptools --upgrade

FROM python-alpine as build-image

# Install aws-lambda-cpp build dependencies
RUN apk add --no-cache \
build-base \
libtool \
autoconf \
automake \
elfutils-dev \
make \
cmake \
libcurl

# Include global arg in this stage of the build
FROM python:3.11-slim

RUN apt -y update && apt -y install gcc python3-dev

ARG FUNCTION_DIR
# Create function directory

WORKDIR ${FUNCTION_DIR}

RUN mkdir -p ${FUNCTION_DIR}

# Copy function code
COPY app ${FUNCTION_DIR}/app

COPY requirements.txt requirements.txt

# Install the runtime interface client
RUN python -m pip install --upgrade pip
RUN python -m pip install \
--target ${FUNCTION_DIR} \
--requirement requirements.txt

FROM python:3.11-slim

RUN apt -y update && apt -y install gcc python3-dev
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}
# Uninstall installation packages
RUN pip uninstall -y wheel setuptools

# Copy in the build image dependencies
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}

ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
CMD [ "app.upload-statistics.lambda_handler" ]

0 comments on commit f501d98

Please sign in to comment.