This repository was archived by the owner on Apr 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
47 lines (40 loc) · 1.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
FROM public.ecr.aws/lambda/python:3.8
ARG PACKAGE_SUFFIX=''
USER root
WORKDIR /tmp
# PACKAGE_SUFFIX = '[all]==2.0.0'
# PACKAGE_SUFFIX = '[all] @ git+https://github.com/awslabs/aws-lambda-powertools-python@v2'
# PACKAGE_SUFFIX = '[all]'
# PACKAGE_SUFFIX = '=='2.0.0'
# PACKAGE_SUFFIX = ' @ git+https://github.com/awslabs/aws-lambda-powertools-python@v2'
# PACKAGE_SUFFIX = ''
RUN yum update -y && yum install -y zip unzip wget tar gzip binutils
# 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
# 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
RUN cd /asset && \
# remove boto3 and botocore (already available in Lambda Runtime)
rm -rf python/boto* && \
# remove boto3 dependencies
rm -rf python/s3transfer* python/*dateutil* python/urllib3* python/six* python/jmespath* && \
# remove debugging symbols
find python -name '*.so' -type f -exec strip "{}" \; && \
# remove tests
find python -wholename "*/tests/*" -type f -delete && \
# remove python bytecode
find python -regex '^.*\(__pycache__\|\.py[co]\)$' -delete