From b89e494358339a1326899d0c3273820d2f213806 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Thu, 3 Aug 2023 21:24:08 +0000 Subject: [PATCH] init --- Dockerfile | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 4 ++++ 2 files changed, 57 insertions(+) create mode 100644 Dockerfile create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8c99c9e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# https://aws.amazon.com/blogs/aws/new-for-aws-lambda-container-image-support/ +# libexec is missing from >=3.17 + +# Stage 1 - bundle base image + runtime +FROM python:3.9-alpine3.16 AS python-alpine + +# Install GCC (Alpine uses musl but we compile and link dependencies with GCC) +RUN apk upgrade -U --available --no-cache && \ + apk add --no-cache \ + libstdc++ + + +# Stage 2 - build function and dependencies +FROM python-alpine AS build-image +ARG TAG="latest" + +# Install aws-lambda-cpp build dependencies +RUN apk upgrade -U --available --no-cache && \ + apk add --no-cache \ + build-base \ + libtool \ + autoconf \ + automake \ + make \ + cmake \ + libcurl \ + libffi-dev \ + libexecinfo-dev \ + openssl-dev + # cargo + +# Install requirements +COPY requirements.txt requirements.txt +RUN export MAKEFLAGS="-j$(nproc)" && \ + pip install -r requirements.txt --target /app + +# Install our app +COPY app.py /app + +# Ser version to our TAG +RUN sed -i -e "s/^__version__ =.*/__version__ = \"${TAG}\"/" /app/app.py + +# Stage 3 - final runtime image +FROM python-alpine + +WORKDIR /app +COPY --from=build-image /app /app + +ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ] +CMD [ "app.handler" ] + +LABEL zero-downtime.net.image.maintainer="stefan@zero-downtime.net" \ + zero-downtime.net.image.license="AGPLv3" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8983bc8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +boto3 +apprise==1.3.0 +humanize +awslambdaric