-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (38 loc) · 2.05 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
FROM lambci/lambda:build-python3.6
ENV LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8
ENV PACKAGE_PREFIX /tmp/python
#RUN pip3 install rasterio --no-binary numpy -t $PACKAGE_PREFIX -U
RUN pip3 install rasterio -t $PACKAGE_PREFIX -U
RUN pip3 install rio-l8qa -t $PACKAGE_PREFIX -U
RUN pip3 install sat-search==0.2.1 -t $PACKAGE_PREFIX -U
RUN pip3 install matplotlib -t $PACKAGE_PREFIX -U
################################################################################
# REDUCE PACKAGE SIZE #
################################################################################
RUN find $PACKAGE_PREFIX -name "*-info" -type d -exec rm -rdf {} +
RUN rm -rdf $PACKAGE_PREFIX/boto3/ \
&& rm -rdf $PACKAGE_PREFIX/botocore/ \
&& rm -rdf $PACKAGE_PREFIX/docutils/ \
&& rm -rdf $PACKAGE_PREFIX/dateutil/ \
&& rm -rdf $PACKAGE_PREFIX/setuptools/ \
&& rm -rdf $PACKAGE_PREFIX/jmespath/ \
&& rm -rdf $PACKAGE_PREFIX/numpy/doc/ \
&& rm -rdf $PACKAGE_PREFIX/numpy/*/tests/ \
&& rm -rdf $PACKAGE_PREFIX/matplotlib/mpl-data/fonts/ \
&& rm -rdf $PACKAGE_PREFIX/matplotlib/mpl-data/sample_data\ \
&& rm -rdf $PACKAGE_PREFIX/matplotlib/mpl-data/images\ \
&& rm -rdf $PACKAGE_PREFIX/matplotlib/testing/ \
&& rm -rdf $PACKAGE_PREFIX/matplotlib/tests/ \
&& rm -rdf $PACKAGE_PREFIX/mpl_toolkits/tests/
# Leave module precompiles for faster Lambda startup
RUN find $PACKAGE_PREFIX -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-36//'); cp $f $n; done;
RUN find $PACKAGE_PREFIX -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf
RUN find $PACKAGE_PREFIX -type f -a -name '*.py' -print0 | xargs -0 rm -f
# Copy source codes
COPY src/* $PACKAGE_PREFIX/
RUN rm -rdf $PACKAGE_PREFIX/test.py
################################################################################
# CREATE ARCHIVE #
################################################################################
RUN cd $PACKAGE_PREFIX && zip -r9q /tmp/package.zip *