1- # STATUS: WIP
21
3- This project is currently in a Work In Progress status. We are doing a global refactor.
4- For the stable version of the docs please refer to https://github.com/lambgeo/docker-lambda/tree/ef66339724b1b7e1a375df912dfd58a9c59ac109
5-
6- # GDAL based docker-lambda
2+ # GDAL based docker image made for AWS Lambda
73
84<p align =" center " >
95 <img src =" https://user-images.githubusercontent.com/10407788/95621320-7b226080-0a3f-11eb-8194-4b55a5555836.png " style =" max-width : 800px ;" alt =" docker-lambda " ></a >
106</p >
117<p align =" center " >
12- <em >AWS lambda (Amazonlinux) like docker images and lambda layer with GDAL.</em >
8+ <em >AWS lambda (Amazonlinux) like docker images with GDAL.</em >
139</p >
1410<p align =" center " >
1511 <a href =" https://github.com/cogeotiff/rio-tiler/actions?query=workflow%3ACI " target =" _blank " >
@@ -21,86 +17,105 @@ For the stable version of the docs please refer to https://github.com/lambgeo/do
2117# Docker Images
2218
2319Based on lambci/lambda-base: build (amazonlinux)
24- - GDAL 3.1.3 (Oct. 2020)
25- - ** lambgeo/lambda-base: gdal3 .1**
26- - ** lambgeo/lambda: gdal3 .1-py3.7**
20+ - GDAL 3.2.0 (Oct. 2020)
21+ - ** lambgeo/lambda-gdal:3.2**
22+
23+ - GDAL 3.1.4 (Oct. 2020)
24+ - ** lambgeo/lambda-gdal:3.1**
2725
2826 - GDAL 2.4.4 (June 2020)
29- - ** lambgeo/lambda-base: gdal2 .4**
30- - ** lambgeo/lambda: gdal2 .4-py3.7**
27+ - ** lambgeo/lambda-gdal:2.4**
28+
29+ - For python 3.7
30+ - ** lambgeo/lambda-gdal:3.2-python3.7**
31+ - ** lambgeo/lambda-gdal:3.1-python3.7**
32+ - ** lambgeo/lambda-gdal:2.4-python3.7**
3133
32- Based on lambci/lambda-base-2: build (amazonlinux2)
33- - GDAL 3.1.3 (Oct. 2020)
34- - ** lambgeo/lambda-base-2: gdal3 .1**
35- - ** lambgeo/lambda: gdal3 .1-py3.8**
34+ Based on lambci/lambda-base-2: build (amazonlinux2) for newer runtimes (e.g python 3.8)
35+ - GDAL 3.2.0 (Oct. 2020)
36+ - ** lambgeo/lambda2-gdal:3.2**
37+
38+ - GDAL 3.1.4 (Oct. 2020)
39+ - ** lambgeo/lambda2-gdal:3.1**
3640
3741 - GDAL 2.4.4 (June 2020)
38- - ** lambgeo/lambda-base-2: gdal2 .4**
39- - ** lambgeo/lambda: gdal2 .4-py3.8**
42+ - ** lambgeo/lambda2-gdal:2.4**
43+
44+ - For python 3.8
45+ - ** lambgeo/lambda-gdal:3.2-python3.8**
46+ - ** lambgeo/lambda-gdal:3.1-python3.8**
47+ - ** lambgeo/lambda-gdal:2.4-python3.8**
4048
49+ ## Creating Lambda packages
4150
42- # Lambda Layers
51+ 1 . Dockerfile
4352
44- ### ** amazonlinux**
53+ ``` Dockerfile
54+ FROM lambgeo/lambda-gdal:3.2-python3.8
4555
46- name | gdal | runtime | version | size (Mb)| unzipped size (Mb)| arn
47- ---| ---| ---| ---| ---| ---| ---
48- gdal24 | 2.4.4| All | 2| 15.4| 50.1| arn:aws:lambda:us-east-1:524387336408:layer:gdal24:2
49- gdal31 | 3.1.3| All | 2| 25| 64.5| arn:aws:lambda:us-east-1:524387336408:layer:gdal31:2
56+ ENV PACKAGE_PREFIX=/var/task
5057
58+ # Copy any local files to the package
59+ COPY handler.py ${PACKAGE_PREFIX}/handler.py
5160
52- ### ** amazonlinux:2 (al2)**
61+ # Install some requirements
62+ RUN pip install numpy rasterio mercantile --no-binary :all: -t ${PACKAGE_PREFIX}/
5363
54- name | gdal | runtime | version | size (Mb)| unzipped size (Mb)| arn
55- ---| ---| ---| ---| ---| ---| ---
56- gdal24-al2 | 2.4.4| All | 1| 14| 41.7| arn:aws:lambda:us-east-1:524387336408:layer:gdal24-al2:1
57- gdal31-al2 | 3.1.3| All | 1| 22.9| 53.6| arn:aws:lambda:us-east-1:524387336408:layer:gdal31-al2:1
64+ # Cleanup the package of useless files
65+ RUN rm -rdf $PACKAGE_PREFIX/boto3/ \
66+ && rm -rdf $PACKAGE_PREFIX/botocore/ \
67+ && rm -rdf $PACKAGE_PREFIX/docutils/ \
68+ && rm -rdf $PACKAGE_PREFIX/dateutil/ \
69+ && rm -rdf $PACKAGE_PREFIX/jmespath/ \
70+ && rm -rdf $PACKAGE_PREFIX/s3transfer/ \
71+ && rm -rdf $PACKAGE_PREFIX/numpy/doc/ \
72+ && rm -rdf $PREFIX/share/doc \
73+ && rm -rdf $PREFIX/share/man \
74+ && rm -rdf $PREFIX/share/hdf*
5875
76+ # Reduce size of the C libs
77+ RUN cd $PREFIX && find lib -name \* .so\* -exec strip {} \;
5978
60- [ Full list of version and ARN] ( /arns.json )
79+ # Copy python files
80+ RUN cd $PACKAGE_PREFIX && zip -r9q /tmp/package.zip *
6181
62- ### Regions
63- - ap-northeast-1
64- - ap-northeast-2
65- - ap-south-1
66- - ap-southeast-1
67- - ap-southeast-2
68- - ca-central-1
69- - eu-central-1
70- - eu-north-1
71- - eu-west-1
72- - eu-west-2
73- - eu-west-3
74- - sa-east-1
75- - us-east-1
76- - us-east-2
77- - us-west-1
78- - us-west-2
82+ # Copy shared libs
83+ RUN cd $PREFIX && zip -r9q --symlinks /tmp/package.zip lib/*.so* share
84+ RUN cd $PREFIX && zip -r9q --symlinks /tmp/package.zip bin/gdal* bin/ogr* bin/geos* bin/nearblack
85+ ```
7986
80- ### content
87+ 2 . Build and create package.zip
8188
89+ ``` bash
90+ docker build --tag package:latest .
91+ docker run --name lambda -w /var/task --volume $( shell pwd) /:/local -itd package:latest bash
92+ docker cp lambda:/tmp/package.zip package.zip
93+ docker stop lambda
94+ docker rm lambda
8295```
83- layer.zip
96+ Package content should be like:
97+ ```
98+ package.zip
8499 |
85- |___ bin/ # Binaries
86100 |___ lib/ # Shared libraries (GDAL, PROJ, GEOS...)
87101 |___ share/ # GDAL/PROJ data directories
102+ |___ rasterio/
103+ ....
104+ |___ handler.py
105+ |___ other python module
88106```
89107
90- ## AWS Lambda config
91-
92- When using lambgeo layer you ** HAVE TO** set GDAL_DATA and PROJ_LIB environment variable.
108+ 3 . Deploy and Set Environment variables
93109
94- - When using lambgeo gdal layer
110+ For Rasterio or other libraries to be aware of GDAL/PROJ C libraries, you need to set up those 2 envs:
111+ - ** GDAL_DATA:** /var/task/share/gdal
112+ - ** PROJ_LIB:** /var/task/share/proj
95113
96- - ** GDAL_DATA:** /opt/share/gdal
97- - ** PROJ_LIB:** /opt/share/proj
114+ ### Other variable
98115
99- - If you create a package using the gdalX.X docker image.
116+ Starting with gdal3.1 (PROJ 7.1), you can set ` PROJ_NETWORK=ON ` to use remote grids: https://proj.org/usage/network.html
100117
101- - ** GDAL_DATA:** /var/task/share/gdal
102- - ** PROJ_LIB:** /var/task/share/proj
103118
104- ### Other variable
119+ ### Refactor
105120
106- Starting with gdal3.1 (PROJ 7.1), you can set ` PROJ_NETWORK=ON ` to use remote grids: https://proj.org/usage/network.html
121+ We recently refactored the repo, to see old documentation please refer to https://github.com/lambgeo/docker-lambda/tree/ef66339724b1b7e1a375df912dfd58a9c59ac109
0 commit comments