Skip to content

Commit 572b499

Browse files
committed
Pre-compile all python code and remove original .py files.
1 parent 876563c commit 572b499

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*
@@ -27,5 +24,9 @@ RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/li
2724
RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/ddup/_ddup.*.so
2825
RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/stack_v2/_stack_v2.*.so
2926

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

0 commit comments

Comments
 (0)