Skip to content

Commit 6470ea6

Browse files
committed
Pre-compile all python code and remove original .py files.
1 parent b78777d commit 6470ea6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ WORKDIR /build
1111
COPY . .
1212
RUN pip install . -t ./python/lib/$runtime/site-packages
1313

14-
# Remove *.pyc files
15-
RUN find ./python/lib/$runtime/site-packages -name \*.pyc -delete
16-
1714
# Remove botocore (40MB) to reduce package size. aws-xray-sdk
1815
# installs it, while it's already provided by the Lambda Runtime.
1916
RUN rm -rf ./python/lib/$runtime/site-packages/botocore*
@@ -29,5 +26,9 @@ RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/st
2926
RUN find . -name "*.dist-info" -type d | xargs rm -rf
3027

3128

29+
RUN python -m compileall -b ./python/lib/$runtime/site-packages
30+
RUN find ./python/lib/$runtime/site-packages -name \*.py -delete
31+
RUN find ./python/lib/$runtime/site-packages -name __pycache__ -type d -exec rm -r {} \+
32+
3233
FROM scratch
3334
COPY --from=builder /build/python /

0 commit comments

Comments
 (0)