You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The layer content will be unzip in `/opt` directory in AWS Lambda. For the python libs to be able to use the C libraries you have to make sure to set 2 important environment variables:
172
+
173
+
-**GDAL_DATA:** /opt/share/gdal
174
+
-**PROJ_LIB:** /opt/share/proj
175
+
176
+
### How To
177
+
178
+
There are 2 ways to use the layers:
179
+
180
+
#### 1. Simple (No dependencies)
181
+
182
+
If you don't need to add more runtime dependencies, you can just create a lambda package (zip file) with you lambda handler.
If your lambda handler needs more dependencies you'll have to use the exact same environment. To ease this you can find the docker images for each lambda on docker hub.
206
+
207
+
- Create a docker file
208
+
209
+
```dockerfile
210
+
FROM lambgeo/lambda-gdal:3.2-al2
211
+
212
+
# We use lambci docker image for the runtime
213
+
FROM lambci/lambda:build-python3.8
214
+
215
+
# Bring C libs from lambgeo/lambda-gdal image
216
+
COPY --from=gdal /opt/lib/ /opt/lib/
217
+
COPY --from=gdal /opt/include/ /opt/include/
218
+
COPY --from=gdal /opt/share/ /opt/share/
219
+
COPY --from=gdal /opt/bin/ /opt/bin/
220
+
ENV \
221
+
GDAL_DATA=/opt/share/gdal \
222
+
PROJ_LIB=/opt/share/proj \
223
+
GDAL_CONFIG=/opt/bin/gdal-config \
224
+
GEOS_CONFIG=/opt/bin/geos-config \
225
+
PATH=/opt/bin:$PATH
226
+
227
+
# Set some useful env
228
+
ENV \
229
+
LANG=en_US.UTF-8 \
230
+
LC_ALL=en_US.UTF-8 \
231
+
CFLAGS="--std=c99"
232
+
233
+
ENV PYTHONUSERBASE=/var/task
234
+
235
+
# Install dependencies
236
+
COPY handler.py $PYTHONUSERBASE/handler.py
237
+
238
+
# Here we use the `--user` option to make sure to not replicate modules.
239
+
RUN pip install rio-tiler --user
240
+
241
+
# Move some files around
242
+
RUN mv ${PYTHONUSERBASE}/lib/python3.8/site-packages/* ${PYTHONUSERBASE}/
243
+
RUN rm -rf ${PYTHONUSERBASE}/lib
244
+
245
+
echo "Create archive"
246
+
RUN cd $PYTHONUSERBASE && zip -r9q /tmp/package.zip *
247
+
```
248
+
249
+
- create package
250
+
```bash
251
+
docker build --tag package:latest .
252
+
docker run --name lambda -w /var/task -itd package:latest bash
0 commit comments