From 491db1a183d5f960e7302af94c9afc2a294a3d88 Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Mon, 11 Mar 2024 21:35:03 -0400 Subject: [PATCH 1/5] feat: Reduce size limits, strip unused ddtrace bins --- Dockerfile | 7 +++---- scripts/check_layer_size.sh | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 757d0c00..73f22276 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,10 +14,6 @@ RUN pip install . -t ./python/lib/$runtime/site-packages # Remove *.pyc files RUN find ./python/lib/$runtime/site-packages -name \*.pyc -delete -# Strip symbols from ddtrace's binaries. -# TODO (AJ): remove when ddtrace fixes this upstream -RUN find . -name '*.so' -exec strip -g {} \; - # Remove botocore (40MB) to reduce package size. aws-xray-sdk # installs it, while it's already provided by the Lambda Runtime. RUN rm -rf ./python/lib/$runtime/site-packages/botocore* @@ -26,6 +22,9 @@ RUN rm -rf ./python/lib/$runtime/site-packages/jsonschema/tests RUN find . -name 'libddwaf.so' -delete RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_taint_tracking/*.so RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_stacktrace*.so +RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/libdd_wrapper.so +RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/ddup/_ddup.*.so +RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/stack_v2/_stack_v2.*.so FROM scratch COPY --from=builder /build/python / diff --git a/scripts/check_layer_size.sh b/scripts/check_layer_size.sh index 9dbd7e99..697b4241 100755 --- a/scripts/check_layer_size.sh +++ b/scripts/check_layer_size.sh @@ -9,8 +9,8 @@ # 7 mb size limit set -e -MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 7 \* 1024) -MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 24 \* 1024) +MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 5 \* 1024) +MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 10 \* 1024) LAYER_FILES_PREFIX="datadog_lambda_py" From a1c1a11572adc99a3cfe9c940fc53f29a17f74d1 Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Mon, 11 Mar 2024 21:37:31 -0400 Subject: [PATCH 2/5] feat: 13m? --- scripts/check_layer_size.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_layer_size.sh b/scripts/check_layer_size.sh index 697b4241..c44f7e8f 100755 --- a/scripts/check_layer_size.sh +++ b/scripts/check_layer_size.sh @@ -10,7 +10,7 @@ # 7 mb size limit set -e MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 5 \* 1024) -MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 10 \* 1024) +MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 13 \* 1024) LAYER_FILES_PREFIX="datadog_lambda_py" From 8ac1eac6d8fa46bcfbdae3948ea644082e68c1cf Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Mon, 11 Mar 2024 21:42:04 -0400 Subject: [PATCH 3/5] feat: Lower zipped --- scripts/check_layer_size.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_layer_size.sh b/scripts/check_layer_size.sh index c44f7e8f..fc61228a 100755 --- a/scripts/check_layer_size.sh +++ b/scripts/check_layer_size.sh @@ -9,7 +9,7 @@ # 7 mb size limit set -e -MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 5 \* 1024) +MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 3 \* 1024) MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 13 \* 1024) From 7944ce23b7b7f6cc26fb8457c4c906abeab63c51 Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Mon, 11 Mar 2024 21:44:11 -0400 Subject: [PATCH 4/5] feat: 4mb zipped then --- scripts/check_layer_size.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_layer_size.sh b/scripts/check_layer_size.sh index fc61228a..84752fa1 100755 --- a/scripts/check_layer_size.sh +++ b/scripts/check_layer_size.sh @@ -9,7 +9,7 @@ # 7 mb size limit set -e -MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 3 \* 1024) +MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 4 \* 1024) MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 13 \* 1024) From 125c145aa171af2729ed262249ec39a791333f31 Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Mon, 11 Mar 2024 22:05:42 -0400 Subject: [PATCH 5/5] feat: remove urllib3 --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 73f22276..396ef25c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ RUN rm -rf ./python/lib/$runtime/site-packages/botocore* RUN rm -rf ./python/lib/$runtime/site-packages/setuptools RUN rm -rf ./python/lib/$runtime/site-packages/jsonschema/tests RUN find . -name 'libddwaf.so' -delete +RUN rm -rf ./python/lib/$runtime/site-packages/urllib3 RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_taint_tracking/*.so RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_stacktrace*.so RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/libdd_wrapper.so