Skip to content

Instantly share code, notes, and snippets.

@tekumara
Created November 21, 2021 11:53
Show Gist options
  • Save tekumara/16ccf7b25a88ee1f6cab220c6db4570a to your computer and use it in GitHub Desktop.
Save tekumara/16ccf7b25a88ee1f6cab220c6db4570a to your computer and use it in GitHub Desktop.
Build a python zip file with dependencies for AWS lambda
FROM public.ecr.aws/lambda/python:3.8 as builder
RUN yum install -y zip
WORKDIR /var/task/
COPY setup.py pyproject.toml ./
COPY src ./src/
RUN pip install --no-cache-dir . --target dist
WORKDIR /var/task/dist
RUN zip --quiet -r9X /var/task/function.zip .
FROM scratch
COPY --from=builder /var/task/function.zip /
@tekumara
Copy link
Author

To build run:

docker build -o dist .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment