sns-alert-hub/Dockerfile

57 lines
1.4 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/
ARG RUNTIME_VERSION="3.9"
2023-05-15 21:08:13 +00:00
# libexec is missing from >=3.17
ARG DISTRO_VERSION="3.16"
2022-02-09 10:57:23 +00:00
# Stage 1 - bundle base image + runtime
FROM python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} 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
2022-02-11 15:40:01 +00:00
# Ser version to our TAG
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"