Created
May 20, 2024 21:52
-
-
Save nford/efbe32e269ba1267275a2a72f9722920 to your computer and use it in GitHub Desktop.
Running Mailbagit in AWS Lambda (Docker/Python)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM --platform=linux/amd64 python:3.12-bookworm | |
# how to set up an alternative base image for lambda | |
# https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-ric | |
COPY ./ ${LAMBDA_TASK_ROOT}/ | |
ENV TZ=America/New_York \ | |
DEBIAN_FRONTEND=noninteractive \ | |
MAILBAGIT_LOG_LEVEL=info \ | |
IN_CONTAINER=true | |
RUN apt-get -y update | |
RUN apt-get -y upgrade | |
RUN apt-get install -y curl | |
RUN apt-get install -y gcc dpkg-dev wget | |
# Lambda runtime interface client | |
RUN pip install awslambdaric | |
# install dependencies | |
RUN pip install -r requirements.txt | |
# wkhtmltopdf deps | |
RUN apt-get install -y xfonts-75dpi xfonts-base | |
RUN pip install libpff-python==20231205 | |
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub > linux_signing_key.pub | |
RUN install -D -o root -g root -m 644 linux_signing_key.pub /etc/apt/keyrings/linux_signing_key.pub | |
RUN sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/linux_signing_key.pub] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list' | |
RUN apt-get update -y | |
RUN apt-get install -y google-chrome-stable | |
# Old libssl dependency of wkhtmltopdf | |
RUN curl -L -o /tmp/libssl1.1_1.1.1w-0+deb11u1_amd64.deb \ | |
http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_amd64.deb | |
RUN dpkg -i /tmp/libssl1.1_1.1.1w-0+deb11u1_amd64.deb | |
RUN curl -L -o /tmp/wkhtmltox_0.12.6-1.buster_amd64.deb \ | |
https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb | |
RUN dpkg -i /tmp/wkhtmltox_0.12.6-1.buster_amd64.deb | |
RUN pip install mailbagit -U | |
# Set runtime interface client as default command for the container runtime | |
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ] | |
# Pass the name of the function handler as an argument to the runtime | |
CMD [ "msgToPdf.handler" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment