From de2a66051db00d439fd82cc03fa82e4e6d26c1d3 Mon Sep 17 00:00:00 2001 From: Aimee Barciauskas Date: Mon, 6 Nov 2023 10:48:57 -0800 Subject: [PATCH] Use efs only for numpy --- infrastructure/aws/lambda/Dockerfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/infrastructure/aws/lambda/Dockerfile b/infrastructure/aws/lambda/Dockerfile index 4fdff36..3fe97a2 100644 --- a/infrastructure/aws/lambda/Dockerfile +++ b/infrastructure/aws/lambda/Dockerfile @@ -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"]