sns-alert-hub/Dockerfile

57 lines
1.5 KiB
Docker
Raw Normal View History

2022-02-09 10:57:23 +00:00
# https://aws.amazon.com/blogs/aws/new-for-aws-lambda-container-image-support/
2023-05-15 21:08:13 +00:00
# libexec is missing from >=3.17
2022-02-09 10:57:23 +00:00
# Stage 1 - bundle base image + runtime
FROM python:3.12-alpine3.19 AS python-alpine
ARG ALPINE="v3.19"
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)
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
RUN apk --no-cache add \
2022-02-09 10:57:23 +00:00
build-base \
libtool \
autoconf \
automake \
make \
cmake \
libcurl \
libffi-dev \
openssl-dev \
libexecinfo-dev@kubezero
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
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"