This repository has been archived by the owner on Jun 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from RemotePixel/arlams
add alarms and reduce package size with rasterio wheels
- Loading branch information
Showing
6 changed files
with
86 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,3 +104,4 @@ ENV/ | |
.serverless | ||
|
||
package.zip | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,51 @@ | ||
FROM remotepixel/amazonlinux-gdal:latest | ||
# Use the official amazonlinux AMI image | ||
FROM amazonlinux:latest | ||
|
||
RUN pip3 install remotepixel --no-binary numpy,rasterio -t /tmp/vendored | ||
# Install apt dependencies | ||
RUN yum install -y \ | ||
gcc gcc-c++ freetype-devel yum-utils findutils openssl-devel | ||
|
||
COPY handler.py /tmp/vendored/handler.py | ||
RUN yum -y groupinstall development | ||
|
||
RUN curl https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz | tar -xJ \ | ||
&& cd Python-3.6.1 \ | ||
&& ./configure --prefix=/usr/local --enable-shared \ | ||
&& make \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm -rf Python-3.6.1 | ||
|
||
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | ||
|
||
RUN pip3 install numpy wheel cython --no-binary numpy | ||
|
||
# Install Python dependencies | ||
RUN pip3 install remotepixel==0.0.2 --no-binary numpy -t /tmp/vendored -U | ||
|
||
#Reduce Lambda package size (<250Mb) | ||
RUN echo "package original size $(du -sh /tmp/vendored | cut -f1)" | ||
RUN find /tmp/vendored \ | ||
\( -type d -a -name test -o -name tests \) \ | ||
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ | ||
-print0 | xargs -0 rm -f | ||
RUN echo "package new size $(du -sh /tmp/vendored | cut -f1)" | ||
RUN du -sh /tmp/vendored | ||
|
||
RUN cd /tmp \ | ||
&& zip -r9q /tmp/package.zip vendored/* | ||
# This is the list of available modules on AWS lambda Python 3 | ||
# ['boto3', 'botocore', 'docutils', 'jmespath', 'pip', 'python-dateutil', 's3transfer', 'setuptools', 'six'] | ||
RUN find /tmp/vendored -name "*-info" -type d -exec rm -rdf {} + | ||
RUN rm -rdf /tmp/vendored/boto3/ | ||
RUN rm -rdf /tmp/vendored/botocore/ | ||
RUN rm -rdf /tmp/vendored/docutils/ | ||
RUN rm -rdf /tmp/vendored/dateutil/ | ||
RUN rm -rdf /tmp/vendored/jmespath/ | ||
RUN rm -rdf /tmp/vendored/s3transfer/ | ||
RUN rm -rdf /tmp/vendored/numpy/doc/ | ||
|
||
# Leave module precompiles for faster Lambda startup | ||
RUN find /tmp/vendored -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-36//'); cp $f $n; done; | ||
RUN find /tmp/vendored -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf | ||
RUN find /tmp/vendored -type f -a -name '*.py' -print0 | xargs -0 rm -f | ||
|
||
RUN du -sh /tmp/vendored | ||
|
||
COPY handler.py /tmp/vendored/handler.py | ||
|
||
RUN cd $APP_DIR/local \ | ||
&& zip --symlinks -r9q /tmp/package.zip lib/*.so* \ | ||
&& zip -r9q /tmp/package.zip share | ||
# Create archive | ||
RUN cd /tmp/vendored && zip -r9q /tmp/package.zip * | ||
|
||
# Cleanup | ||
RUN rm -rf /tmp/vendored/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "remotepixel-api", | ||
"version": "1.0.0", | ||
"description": "Create a highly customizable `serverless` tile server for Amazon's Landsat Public Dataset", | ||
"devDependencies": { | ||
"serverless-plugin-aws-alerts": "^1.2.4", | ||
"serverless": "^1.23.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/remotepixel/landsat-tiler.git" | ||
}, | ||
"author": "Vincent Sarago" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters