2022-02-09 10:57:23 +00:00
|
|
|
# Stage 1 - bundle base image + runtime
|
2024-11-08 03:02:34 +00:00
|
|
|
FROM python:3.13-alpine3.20 AS python-alpine
|
2024-09-12 06:17:31 +00:00
|
|
|
ARG ALPINE="v3.20"
|
2022-02-10 16:37:37 +00:00
|
|
|
|
2022-02-09 10:57:23 +00:00
|
|
|
# Install GCC (Alpine uses musl but we compile and link dependencies with GCC)
|
2024-04-05 13:27:05 +00:00
|
|
|
RUN echo "@kubezero https://cdn.zero-downtime.net/alpine/${ALPINE}/kubezero" >> /etc/apk/repositories && \
|
|
|
|
wget -q -O /etc/apk/keys/stefan@zero-downtime.net-61bb6bfb.rsa.pub https://cdn.zero-downtime.net/alpine/stefan@zero-downtime.net-61bb6bfb.rsa.pub
|
|
|
|
|
|
|
|
RUN apk -U --no-cache upgrade && \
|
|
|
|
apk --no-cache add \
|
2022-02-09 10:57:23 +00:00
|
|
|
libstdc++
|
|
|
|
|
2022-02-09 22:24:12 +00:00
|
|
|
|
2022-02-09 10:57:23 +00:00
|
|
|
# Stage 2 - build function and dependencies
|
|
|
|
FROM python-alpine AS build-image
|
2022-02-11 15:40:01 +00:00
|
|
|
ARG TAG="latest"
|
2022-02-10 16:37:37 +00:00
|
|
|
|
2022-02-09 10:57:23 +00:00
|
|
|
# Install aws-lambda-cpp build dependencies
|
2024-04-05 13:27:05 +00:00
|
|
|
RUN apk --no-cache add \
|
2022-02-09 10:57:23 +00:00
|
|
|
build-base \
|
|
|
|
libtool \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
|
|
|
make \
|
|
|
|
cmake \
|
|
|
|
libcurl \
|
|
|
|
libffi-dev \
|
2024-04-05 13:27:05 +00:00
|
|
|
openssl-dev \
|
2024-09-12 06:17:31 +00:00
|
|
|
elfutils-dev
|
2022-02-09 10:57:23 +00:00
|
|
|
# cargo
|
|
|
|
|
|
|
|
# Install requirements
|
|
|
|
COPY requirements.txt requirements.txt
|
2022-02-10 16:37:37 +00:00
|
|
|
RUN export MAKEFLAGS="-j$(nproc)" && \
|
|
|
|
pip install -r requirements.txt --target /app
|
|
|
|
|
|
|
|
# Install our app
|
|
|
|
COPY app.py /app
|
2022-02-09 10:57:23 +00:00
|
|
|
|
2023-08-14 10:22:11 +00:00
|
|
|
# Set internal __version__ to our own container TAG
|
2022-02-11 15:40:01 +00:00
|
|
|
RUN sed -i -e "s/^__version__ =.*/__version__ = \"${TAG}\"/" /app/app.py
|
2022-02-09 10:57:23 +00:00
|
|
|
|
|
|
|
# Stage 3 - final runtime image
|
2022-02-11 12:07:07 +00:00
|
|
|
FROM python-alpine
|
2022-02-10 16:37:37 +00:00
|
|
|
|
2024-09-12 19:03:44 +00:00
|
|
|
RUN apk --no-cache add \
|
|
|
|
zstd-libs
|
|
|
|
|
2022-02-10 16:37:37 +00:00
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=build-image /app /app
|
2022-02-09 10:57:23 +00:00
|
|
|
|
|
|
|
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
|
|
|
|
CMD [ "app.handler" ]
|
2022-02-11 15:40:01 +00:00
|
|
|
|
|
|
|
LABEL zero-downtime.net.image.maintainer="stefan@zero-downtime.net" \
|
|
|
|
zero-downtime.net.image.license="AGPLv3"
|