-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
47 lines (40 loc) · 1.36 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==1.* -t /asset/python "aws-lambda-powertools$PACKAGE_SUFFIX"
# Removing nonessential files
RUN cd /asset/python && \
# remove boto3 and botocore (already available in Lambda Runtime)
rm -rf boto* && \
# remove boto3 dependencies
rm -rf s3transfer* *dateutil* urllib3* six* jmespath* && \
# remove debugging symbols
find . -name '*.so' -type f -exec strip "{}" \; && \
# remove tests
find . -wholename "*/tests/*" -type f -delete && \
# remove python bytecode
find . -regex '^.*\(__pycache__\|\.py[co]\)$' -delete