Docker Community Forums

Share and learn in the Docker community.

Zip files (for AWS Lambda), but exclude certain folders

The following is my Dockerfile :

FROM lambci/lambda:build-python3.7
COPY lambda_function.py .

RUN python3 -m venv venv
RUN . venv/bin/activate

RUN pip install pystan==2.18
RUN pip install fbprophet

# Create zip
RUN pushd /var/task/venv/lib/python3.7/site-packages/
# Exclude folders in .lambdaignore
RUN zip -r -9 -q /var/task/lambda.zip *
RUN popd
RUN zip -9r lambda.zip lambda_function.py

You can see one comment where I wrote:

Exclude folders in .lambdaignore

That’s the point where I am stuck. Before building the .zip file. I want to exclude the following two folders:

/var/task/venv/lib/python3.7/site-packages/pystan/stan/src
/var/task/venv/lib/python3.7/site-packages/pystan/stan/lib/stan_math/lib

Ideally, I just add a .lambdaignore file and each line is just excluded from the .zip That way it would be more flexible. Can you help me with that?