Skip to content

Commit

Permalink
Use efs only for numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
abarciauskas-bgse committed Nov 6, 2023
1 parent fc3059c commit de2a660
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions infrastructure/aws/lambda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ COPY titiler/ titiler/
# we have to force using old package version that seems `almost` compatible with Lambda env botocore
# https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
RUN pip install --upgrade pip
RUN pip install . "mangum>=0.10.0" "botocore==1.29.76" "aiobotocore==2.5.0" -t /mnt/efs/libraries --no-binary pydantic
RUN pip install . "mangum>=0.10.0" "botocore==1.29.76" "aiobotocore==2.5.0" -t /asset --no-binary pydantic

# Reduce package size and remove useless files
RUN cd /mnt/efs/libraries && find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
RUN cd /mnt/efs/libraries && find . -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf
RUN cd /mnt/efs/libraries && find . -type f -a -name '*.py' -print0 | xargs -0 rm -f
RUN find /mnt/efs/libraries -type d -a -name 'tests' -print0 | xargs -0 rm -rf
RUN rm -rdf /mnt/efs/libraries/numpy/doc/ /mnt/efs/libraries/bin /mnt/efs/libraries/geos_license /mnt/efs/libraries/Misc
RUN rm -rdf /mnt/efs/libraries/boto3*
RUN rm -rdf /mnt/efs/libraries/botocore*
ENV PYTHONPATH=/mnt/efs/libraries
RUN cd /asset && find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
RUN cd /asset && find . -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf
RUN cd /asset && find . -type f -a -name '*.py' -print0 | xargs -0 rm -f
RUN find /asset -type d -a -name 'tests' -print0 | xargs -0 rm -rf
RUN rm -rdf /asset/numpy/doc/ /asset/bin /asset/geos_license /asset/Misc
RUN rm -rdf /asset/boto3*
RUN rm -rdf /asset/botocore*
RUN mv /asset/numpy /mnt/efs/libraries/
ENV PYTHONPATH="${PYTHONPATH}:/mnt/efs/libraries"

COPY infrastructure/aws/lambda/handler.py /mnt/efs/libraries/handler.py
COPY infrastructure/aws/lambda/handler.py /asset/handler.py

CMD ["echo", "hello world"]

0 comments on commit de2a660

Please sign in to comment.