sns-alert-hub/Dockerfile

54 lines
1.3 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
2023-08-04 13:55:43 +00:00
FROM python:3.9-alpine3.16 AS python-alpine
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 apk upgrade -U --available --no-cache && \
apk add --no-cache \
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 upgrade -U --available --no-cache && \
apk add --no-cache \
2022-02-09 10:57:23 +00:00
build-base \
libtool \
autoconf \
automake \
make \
cmake \
libcurl \
libffi-dev \
2023-05-15 21:08:13 +00:00
libexecinfo-dev \
2022-02-09 10:57:23 +00:00
openssl-dev
# 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"