From ef9a4a7154b707f09daf441dbc216fd33dc5ce98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Fri, 7 Oct 2022 09:48:18 +0200 Subject: [PATCH 1/2] feat: optimize Python layer by always building wheels --- layer/Python/Dockerfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/layer/Python/Dockerfile b/layer/Python/Dockerfile index 5541e04..72ca48c 100644 --- a/layer/Python/Dockerfile +++ b/layer/Python/Dockerfile @@ -12,7 +12,24 @@ WORKDIR /tmp RUN yum update -y && yum install -y zip unzip wget tar gzip binutils -RUN pip install -t /asset/python aws-lambda-powertools$PACKAGE_SUFFIX +# Install build essentials +RUN yum install -y \ + boost-devel \ + jemalloc-devel \ + bison \ + make \ + gcc \ + gcc-c++ \ + flex \ + autoconf \ + zip \ + git \ + ninja-build + +# Install cython to generate native code +RUN pip install --upgrade pip wheel && pip install --upgrade cython + +RUN CFLAGS="-Os -g0 -s" pip install --no-binary pydantic -t /asset/python aws-lambda-powertools$PACKAGE_SUFFIX # Removing nonessential files RUN cd /asset && \ From e3493634641ea30bed6d100e8c708709f5578fcd Mon Sep 17 00:00:00 2001 From: Heitor Lessa Date: Fri, 7 Oct 2022 13:51:03 +0200 Subject: [PATCH 2/2] chore: add notes on why we came up with build flags --- layer/Python/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layer/Python/Dockerfile b/layer/Python/Dockerfile index 72ca48c..7e6a979 100644 --- a/layer/Python/Dockerfile +++ b/layer/Python/Dockerfile @@ -28,7 +28,7 @@ RUN yum install -y \ # Install cython to generate native code RUN pip install --upgrade pip wheel && pip install --upgrade cython - +# Optimize binary size and strip debugging symbols for optimum size RUN CFLAGS="-Os -g0 -s" pip install --no-binary pydantic -t /asset/python aws-lambda-powertools$PACKAGE_SUFFIX # Removing nonessential files