Skip to content

Commit ece4d11

Browse files
Merge pull request #64 from philvarner/pv/polish
update and cleanup after yum install
2 parents 90dee90 + e2d7543 commit ece4d11

File tree

3 files changed

+50
-36
lines changed

3 files changed

+50
-36
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
matrix:
2323
gdal-version: [3.6]
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
2626

2727
- name: Set up Python
28-
uses: actions/setup-python@v2
28+
uses: actions/setup-python@v4
2929
with:
3030
python-version: 3.9
3131

@@ -125,14 +125,14 @@ jobs:
125125
needs: [deploy]
126126
runs-on: ubuntu-latest
127127
steps:
128-
- uses: actions/checkout@v2
128+
- uses: actions/checkout@v4
129129

130130
- name: Set up Python
131-
uses: actions/setup-python@v2
131+
uses: actions/setup-python@v4
132132
with:
133133
python-version: 3.9
134134

135-
- uses: actions/setup-node@v1
135+
- uses: actions/setup-node@v4
136136

137137
- name: Configure AWS Credentials
138138
uses: aws-actions/configure-aws-credentials@v1

README.md

+38-29
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11

2-
# GDAL based docker image made for AWS Lambda
2+
# GDAL-based Docker Image for AWS Lambda
33

4+
<!-- markdownlint-disable MD033 -->
45
<p align="center">
56
<img src="https://user-images.githubusercontent.com/10407788/95621320-7b226080-0a3f-11eb-8194-4b55a5555836.png" style="max-width: 800px;" alt="docker-lambda"></a>
67
</p>
78
<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>
910
</p>
1011
<p align="center">
1112
<a href="https://github.com/lambgeo/docker-lambda/actions?query=workflow%3ACI" target="_blank">
1213
<img src="https://github.com/lambgeo/docker-lambda/workflows/CI/badge.svg" alt="Test">
1314
</a>
1415
</p>
16+
<!-- markdownlint-enable -->
1517

16-
17-
# Docker Images
18+
## Docker Images
1819

1920
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)
2224

2325
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**
2826

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**
3031

31-
# Creating Lambda packages
32+
see: <https://github.com/lambgeo/docker-lambda/pkgs/container/lambda-gdal>
3233

33-
## Using
34+
## Creating Lambda packages
3435

35-
### 1. Create Dockerfile
36+
### Using
37+
38+
#### 1. Create Dockerfile
3639

3740
```Dockerfile
3841
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
8689
RUN cd $PREFIX && zip -r9q --symlinks /tmp/package.zip bin/gdal* bin/ogr* bin/geos* bin/nearblack
8790
```
8891

89-
### 2. Build and create package.zip
92+
#### 2. Build and create package.zip
9093

9194
```bash
9295
docker build --tag package:latest .
@@ -95,8 +98,10 @@ docker cp lambda:/tmp/package.zip package.zip
9598
docker stop lambda
9699
docker rm lambda
97100
```
101+
98102
Package content should be like:
99-
```
103+
104+
```text
100105
package.zip
101106
|
102107
|___ bin/ # GDAL binaries
@@ -108,27 +113,29 @@ package.zip
108113
|___ other python module
109114
```
110115

111-
### 3. Deploy and Set Environment variables
116+
#### 3. Deploy and Set Environment variables
112117

113118
Libraries might need to be aware of GDAL/PROJ C libraries so you **HAVE TO** to set up those 2 envs:
119+
114120
- **GDAL_DATA:** /var/task/share/gdal
115121
- **PROJ_LIB:** /var/task/share/proj
116122

117123
Other variables:
118124

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).
120126

121127
---
122128

123-
# AWS Lambda Layers
129+
## AWS Lambda Layers
124130

125131
| gdal | amazonlinux version | size (Mb) | unzipped size (Mb) | arn |
126132
| ---- | ------------------- | --------- | ------------------ | ----------------------------------------------------------- |
127133
| 3.6 | 2 | 26.8 | 76.1 | arn:aws:lambda:{REGION}:524387336408:layer:gdal36:{VERSION} |
128134

129135
see [/layer.json](/layer.json) for the list of arns
130136

131-
##### Find the arn version
137+
### Find the arn version
138+
132139
```bash
133140
cat layer.json| jq '.[] | select(.region == "us-west-2")'
134141
{
@@ -143,7 +150,7 @@ cat layer.json| jq '.[] | select(.region == "us-west-2")'
143150
}
144151
```
145152

146-
#### archived layers
153+
### archived layers
147154

148155
| gdal | amazonlinux version | size (Mb) | unzipped size (Mb) | arn |
149156
| ---- | ------------------- | --------- | ------------------ | --------------------------------------------------------------- |
@@ -157,7 +164,7 @@ see [/archived_layer.json](/archived_layer.json) for the list of arns
157164

158165
**Layer content:**
159166

160-
```
167+
```text
161168
layer.zip
162169
|
163170
|___ bin/ # Binaries
@@ -170,11 +177,11 @@ At Lambda runtime, the layer content will be unzipped in the `/opt` directory. T
170177
- **GDAL_DATA:** /opt/share/gdal
171178
- **PROJ_LIB:** /opt/share/proj
172179

173-
## How To Use (Create a Lambda Package)
180+
### How To Use (Create a Lambda Package)
174181

175182
There are 2 ways to use the layers:
176183

177-
### 1. Simple (No dependencies)
184+
#### 1. Simple (No dependencies)
178185

179186
If you don't need to add more runtime dependencies, you can just create a lambda package (zip file) with your lambda handler.
180187

@@ -186,24 +193,24 @@ zip -r9q package.zip handler.py
186193

187194
**Content:**
188195

189-
```
196+
```text
190197
package.zip
191198
|___ handler.py # aws lambda python handler
192199
```
193200

194201
**AWS Lambda Config:**
202+
195203
- arn: `arn:aws:lambda:us-east-1:524387336408:layer:gdal36:1` (example)
196204
- env:
197205
- **GDAL_DATA:** /opt/share/gdal
198206
- **PROJ_LIB:** /opt/share/proj
199207
- lambda handler: `handler.handler`
200208

201-
202-
### 2. Advanced (need other dependencies)
209+
#### 2. Advanced (need other dependencies)
203210

204211
If your lambda handler needs more dependencies you'll have to use the exact same environment to create the package.
205212

206-
#### Create a Dockerfile
213+
##### Create a Dockerfile
207214

208215
```dockerfile
209216
FROM ghcr.io/lambgeo/lambda-gdal:3.6 as gdal
@@ -239,6 +246,7 @@ RUN cd $PACKAGE_PREFIX && zip -r9q /tmp/package.zip *
239246
```
240247

241248
- create package
249+
242250
```bash
243251
docker build --tag package:latest .
244252
docker run --name lambda -w /var/task -itd package:latest bash
@@ -249,7 +257,7 @@ docker rm lambda
249257

250258
**Content:**
251259

252-
```
260+
```text
253261
package.zip
254262
|___ handler.py # aws lambda python handler
255263
|___ module1/ # dependencies
@@ -259,6 +267,7 @@ package.zip
259267
```
260268

261269
**AWS Lambda Config:**
270+
262271
- arn: `arn:aws:lambda:us-east-1:524387336408:layer:gdal36:1` (example)
263272
- env:
264273
- **GDAL_DATA:** /opt/share/gdal

dockerfiles/Dockerfile.gdal3.6

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ FROM public.ecr.aws/lambda/provided:al2 as builder
22

33
LABEL maintainer="lambgeo <[email protected]>"
44

5-
RUN yum makecache fast
6-
RUN yum install -y git autoconf libtool flex bison cmake make tar gzip gcc gcc-c++ automake16 libpng-devel nasm libxml2-devel readline-devel openssl-devel curl-devel cmake3
5+
RUN yum update -y && \
6+
yum install -y git autoconf libtool flex bison cmake make \
7+
tar gzip gcc gcc-c++ automake16 libpng-devel nasm \
8+
libxml2-devel readline-devel openssl-devel curl-devel \
9+
cmake3 && \
10+
yum clean all && \
11+
rm -rf /var/cache/yum /var/lib/yum/history
712

813
ENV PREFIX /opt
914

0 commit comments

Comments
 (0)