1
1
2
- # GDAL based docker image made for AWS Lambda
2
+ # GDAL- based Docker Image for AWS Lambda
3
3
4
+ <!-- markdownlint-disable MD033 -->
4
5
<p align =" center " >
5
6
<img src =" https://user-images.githubusercontent.com/10407788/95621320-7b226080-0a3f-11eb-8194-4b55a5555836.png " style =" max-width : 800px ;" alt =" docker-lambda " ></a >
6
7
</p >
7
8
<p align =" center " >
8
- <em >AWS lambda (Amazonlinux) like docker images with GDAL.</em >
9
+ <em >AWS Lambda (Amazonlinux) like Docker images with GDAL.</em >
9
10
</p >
10
11
<p align =" center " >
11
12
<a href =" https://github.com/lambgeo/docker-lambda/actions?query=workflow%3ACI " target =" _blank " >
12
13
<img src="https://github.com/lambgeo/docker-lambda/workflows/CI/badge.svg" alt="Test">
13
14
</a >
14
15
</p >
16
+ <!-- markdownlint-enable -->
15
17
16
-
17
- # Docker Images
18
+ ## Docker Images
18
19
19
20
Based on ` public.ecr.aws/lambda/provided:al2 ` (AmazonLinux 2)
20
- - GDAL 3.6
21
- - ** ghcr.io/lambgeo/lambda-gdal:3.6** (Apr 2023)
21
+
22
+ - GDAL 3.6
23
+ - ** ghcr.io/lambgeo/lambda-gdal:3.6** (Apr 2023)
22
24
23
25
Runtimes images:
24
- - Python (based on ` public.ecr.aws/lambda/python:{version} ` )
25
- - ** ghcr.io/lambgeo/lambda-gdal:3.6-python3.9**
26
- - ** ghcr.io/lambgeo/lambda-gdal:3.6-python3.10**
27
- - ** ghcr.io/lambgeo/lambda-gdal:3.6-python3.11**
28
26
29
- see: https://github.com/lambgeo/docker-lambda/pkgs/container/lambda-gdal
27
+ - Python (based on ` public.ecr.aws/lambda/python:{version} ` )
28
+ - ** ghcr.io/lambgeo/lambda-gdal:3.6-python3.9**
29
+ - ** ghcr.io/lambgeo/lambda-gdal:3.6-python3.10**
30
+ - ** ghcr.io/lambgeo/lambda-gdal:3.6-python3.11**
30
31
31
- # Creating Lambda packages
32
+ see: < https://github.com/lambgeo/docker-lambda/pkgs/container/lambda-gdal >
32
33
33
- ## Using
34
+ ## Creating Lambda packages
34
35
35
- ### 1. Create Dockerfile
36
+ ### Using
37
+
38
+ #### 1. Create Dockerfile
36
39
37
40
``` Dockerfile
38
41
FROM ghcr.io/lambgeo/lambda-gdal:3.6 as gdal
@@ -86,7 +89,7 @@ RUN cd $PREFIX && zip -r9q --symlinks /tmp/package.zip lib/*.so* share
86
89
RUN cd $PREFIX && zip -r9q --symlinks /tmp/package.zip bin/gdal* bin/ogr* bin/geos* bin/nearblack
87
90
```
88
91
89
- ### 2. Build and create package.zip
92
+ #### 2. Build and create package.zip
90
93
91
94
``` bash
92
95
docker build --tag package:latest .
@@ -95,8 +98,10 @@ docker cp lambda:/tmp/package.zip package.zip
95
98
docker stop lambda
96
99
docker rm lambda
97
100
```
101
+
98
102
Package content should be like:
99
- ```
103
+
104
+ ``` text
100
105
package.zip
101
106
|
102
107
|___ bin/ # GDAL binaries
@@ -108,27 +113,29 @@ package.zip
108
113
|___ other python module
109
114
```
110
115
111
- ### 3. Deploy and Set Environment variables
116
+ #### 3. Deploy and Set Environment variables
112
117
113
118
Libraries might need to be aware of GDAL/PROJ C libraries so you ** HAVE TO** to set up those 2 envs:
119
+
114
120
- ** GDAL_DATA:** /var/task/share/gdal
115
121
- ** PROJ_LIB:** /var/task/share/proj
116
122
117
123
Other variables:
118
124
119
- Starting with gdal3.1 (PROJ 7.1), you can set ` PROJ_NETWORK=ON ` to use remote grids: https://proj.org/usage/network.html
125
+ Starting with gdal3.1 (PROJ 7.1), you can set ` PROJ_NETWORK=ON ` to use [ remote grids] ( https://proj.org/usage/network.html ) .
120
126
121
127
---
122
128
123
- # AWS Lambda Layers
129
+ ## AWS Lambda Layers
124
130
125
131
| gdal | amazonlinux version | size (Mb) | unzipped size (Mb) | arn |
126
132
| ---- | ------------------- | --------- | ------------------ | ----------------------------------------------------------- |
127
133
| 3.6 | 2 | 26.8 | 76.1 | arn:aws:lambda:{REGION}:524387336408:layer:gdal36:{VERSION} |
128
134
129
135
see [ /layer.json] ( /layer.json ) for the list of arns
130
136
131
- ##### Find the arn version
137
+ ### Find the arn version
138
+
132
139
``` bash
133
140
cat layer.json| jq ' .[] | select(.region == "us-west-2")'
134
141
{
@@ -143,7 +150,7 @@ cat layer.json| jq '.[] | select(.region == "us-west-2")'
143
150
}
144
151
```
145
152
146
- #### archived layers
153
+ ### archived layers
147
154
148
155
| gdal | amazonlinux version | size (Mb) | unzipped size (Mb) | arn |
149
156
| ---- | ------------------- | --------- | ------------------ | --------------------------------------------------------------- |
@@ -157,7 +164,7 @@ see [/archived_layer.json](/archived_layer.json) for the list of arns
157
164
158
165
** Layer content:**
159
166
160
- ```
167
+ ``` text
161
168
layer.zip
162
169
|
163
170
|___ bin/ # Binaries
@@ -170,11 +177,11 @@ At Lambda runtime, the layer content will be unzipped in the `/opt` directory. T
170
177
- ** GDAL_DATA:** /opt/share/gdal
171
178
- ** PROJ_LIB:** /opt/share/proj
172
179
173
- ## How To Use (Create a Lambda Package)
180
+ ### How To Use (Create a Lambda Package)
174
181
175
182
There are 2 ways to use the layers:
176
183
177
- ### 1. Simple (No dependencies)
184
+ #### 1. Simple (No dependencies)
178
185
179
186
If you don't need to add more runtime dependencies, you can just create a lambda package (zip file) with your lambda handler.
180
187
@@ -186,24 +193,24 @@ zip -r9q package.zip handler.py
186
193
187
194
** Content:**
188
195
189
- ```
196
+ ``` text
190
197
package.zip
191
198
|___ handler.py # aws lambda python handler
192
199
```
193
200
194
201
** AWS Lambda Config:**
202
+
195
203
- arn: ` arn:aws:lambda:us-east-1:524387336408:layer:gdal36:1 ` (example)
196
204
- env:
197
205
- ** GDAL_DATA:** /opt/share/gdal
198
206
- ** PROJ_LIB:** /opt/share/proj
199
207
- lambda handler: ` handler.handler `
200
208
201
-
202
- ### 2. Advanced (need other dependencies)
209
+ #### 2. Advanced (need other dependencies)
203
210
204
211
If your lambda handler needs more dependencies you'll have to use the exact same environment to create the package.
205
212
206
- #### Create a Dockerfile
213
+ ##### Create a Dockerfile
207
214
208
215
``` dockerfile
209
216
FROM ghcr.io/lambgeo/lambda-gdal:3.6 as gdal
@@ -239,6 +246,7 @@ RUN cd $PACKAGE_PREFIX && zip -r9q /tmp/package.zip *
239
246
```
240
247
241
248
- create package
249
+
242
250
``` bash
243
251
docker build --tag package:latest .
244
252
docker run --name lambda -w /var/task -itd package:latest bash
@@ -249,7 +257,7 @@ docker rm lambda
249
257
250
258
** Content:**
251
259
252
- ```
260
+ ``` text
253
261
package.zip
254
262
|___ handler.py # aws lambda python handler
255
263
|___ module1/ # dependencies
@@ -259,6 +267,7 @@ package.zip
259
267
```
260
268
261
269
** AWS Lambda Config:**
270
+
262
271
- arn: ` arn:aws:lambda:us-east-1:524387336408:layer:gdal36:1 ` (example)
263
272
- env:
264
273
- ** GDAL_DATA:** /opt/share/gdal
0 commit comments