-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (40 loc) · 1.35 KB
/
Dockerfile
File metadata and controls
46 lines (40 loc) · 1.35 KB
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
# Pull the base image with python 3.8 as a runtime for your Lambda
FROM public.ecr.aws/lambda/python:3.8
# Install OS packages for Pillow-SIMD
RUN yum -y install tar gzip zlib freetype-devel \
gcc \
ghostscript \
lcms2-devel \
libffi-devel \
libimagequant-devel \
libjpeg-devel \
libraqm-devel \
libtiff-devel \
libwebp-devel \
make \
openjpeg2-devel \
rh-python36 \
rh-python36-python-virtualenv \
sudo \
tcl-devel \
tk-devel \
tkinter \
which \
xorg-x11-server-Xvfb \
zlib-devel \
&& yum clean all
# Copy the earlier created requirements.txt file to the container
COPY requirements.txt ./
# Install the python requirements from requirements.txt
RUN python3.8 -m pip install -r requirements.txt
# Replace Pillow with Pillow-SIMD to take advantage of AVX2
RUN pip uninstall -y pillow && CC="cc -mavx2" pip install -U --force-reinstall pillow-simd
# Copy the earlier created app.py file to the container
COPY app.py ./
# Download ResNet50 and store it in a directory
RUN mkdir models
RUN curl -L https://tfhub.dev/google/universal-sentence-encoder/4?tf-hub-format=compressed -o ./models/universal-sentence-encoder_4.tar.gz
RUN tar -xf models/universal-sentence-encoder_4.tar.gz -C models/
RUN rm -r models/universal-sentence-encoder_4.tar.gz
# Set the CMD to your handler
CMD ["app.lambda_handler"]