Skip to content

Commit 93813d3

Browse files
authored
Merge pull request #28 from wongcht/support-arm64
Create arm64 arch image
2 parents 948359a + 400140f commit 93813d3

6 files changed

Lines changed: 186 additions & 61 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 144 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ env:
2121

2222
jobs:
2323
build:
24-
runs-on: ubuntu-latest
2524
if: "!contains(github.event.head_commit.message, '[skip ci]')"
25+
strategy:
26+
matrix:
27+
arch: [amd64, arm64]
28+
include:
29+
- arch: amd64
30+
runner: ubuntu-24.04
31+
- arch: arm64
32+
runner: ubuntu-24.04-arm
33+
runs-on: ${{ matrix.runner }}
2634
steps:
2735
- uses: actions/checkout@v6
2836

@@ -49,37 +57,39 @@ jobs:
4957
- name: Build
5058
uses: docker/build-push-action@v6
5159
with:
52-
platforms: linux/amd64
60+
platforms: linux/${{ matrix.arch }}
5361
context: .
5462
load: true
5563
file: dockerfiles/Dockerfile
5664
build-args: |
5765
GDAL_VERSION=${{ env.GDAL_VERSION }}
58-
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}
59-
cache-from: type=gha
60-
cache-to: type=gha,mode=max
66+
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-${{ matrix.arch }}
67+
cache-from: type=gha,scope=${{ matrix.arch }}
68+
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
6169

6270
- name: Test
6371
run: |
6472
docker run \
65-
--platform=linux/amd64 \
6673
--entrypoint bash \
6774
-v ${{ github.workspace }}:/local \
68-
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }} \
75+
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-${{ matrix.arch }} \
6976
/local/tests/tests.sh
7077
71-
deploy:
78+
deploy-gdal:
7279
needs: [build]
73-
runs-on: ubuntu-latest
7480
if: contains(github.ref, 'tags') && github.event_name == 'push'
81+
strategy:
82+
matrix:
83+
arch: [amd64, arm64]
84+
include:
85+
- arch: amd64
86+
runner: ubuntu-24.04
87+
- arch: arm64
88+
runner: ubuntu-24.04-arm
89+
runs-on: ${{ matrix.runner }}
7590
steps:
7691
- uses: actions/checkout@v6
7792

78-
- name: Set up Python
79-
uses: actions/setup-python@v6
80-
with:
81-
python-version: '3.13'
82-
8393
- name: Set up Docker Buildx
8494
uses: docker/setup-buildx-action@v3
8595

@@ -90,54 +100,144 @@ jobs:
90100
username: ${{ github.repository_owner }}
91101
password: ${{ secrets.GITHUB_TOKEN }}
92102

93-
- name: Configure AWS Credentials
94-
uses: aws-actions/configure-aws-credentials@v6
95-
with:
96-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
97-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
98-
aws-region: us-east-1
99-
100-
- name: Publish docker image
103+
- name: Publish docker image (${{ matrix.arch }})
101104
uses: docker/build-push-action@v6
102105
with:
103-
platforms: linux/amd64
106+
platforms: linux/${{ matrix.arch }}
104107
context: .
105108
file: dockerfiles/Dockerfile
106109
build-args: |
107110
GDAL_VERSION=${{ env.GDAL_VERSION }}
108111
push: true
109-
cache-from: type=gha
110-
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}
112+
cache-from: type=gha,scope=${{ matrix.arch }}
113+
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
114+
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-${{ matrix.arch }}
115+
116+
deploy-gdal-manifest:
117+
needs: [deploy-gdal]
118+
runs-on: ubuntu-24.04
119+
if: contains(github.ref, 'tags') && github.event_name == 'push'
120+
steps:
121+
- name: Login to Github
122+
uses: docker/login-action@v3
123+
with:
124+
registry: ghcr.io
125+
username: ${{ github.repository_owner }}
126+
password: ${{ secrets.GITHUB_TOKEN }}
127+
128+
- name: Create multi-arch manifest
129+
run: |
130+
docker buildx imagetools create \
131+
-t ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }} \
132+
ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-amd64 \
133+
ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-arm64
134+
135+
deploy-layers:
136+
needs: [deploy-gdal]
137+
if: contains(github.ref, 'tags') && github.event_name == 'push'
138+
strategy:
139+
matrix:
140+
include:
141+
- arch: amd64
142+
lambda_arch: x86_64
143+
runner: ubuntu-24.04
144+
- arch: arm64
145+
lambda_arch: arm64
146+
runner: ubuntu-24.04-arm
147+
runs-on: ${{ matrix.runner }}
148+
steps:
149+
- uses: actions/checkout@v6
150+
151+
- name: Set up Python
152+
uses: actions/setup-python@v6
153+
with:
154+
python-version: '3.13'
155+
156+
- name: Configure AWS Credentials
157+
uses: aws-actions/configure-aws-credentials@v6
158+
with:
159+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
160+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
161+
aws-region: us-east-1
111162

112-
- name: Build and Deploy layers
163+
- name: Build and Deploy layer (${{ matrix.arch }})
113164
run: |
114165
python -m pip install boto3 click
115166
docker run \
116-
--platform=linux/amd64 \
117167
--entrypoint bash \
168+
-e OUTPUT_ZIP=package-${{ matrix.arch }}.zip \
118169
-v ${{ github.workspace }}:/local \
119-
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }} \
170+
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-${{ matrix.arch }} \
120171
/local/scripts/create-layer.sh
121-
python scripts/deploy.py ${{ env.GDAL_VERSION_TAG }} --deploy
172+
python scripts/deploy.py ${{ env.GDAL_VERSION_TAG }} --arch ${{ matrix.lambda_arch }} --package package-${{ matrix.arch }}.zip --deploy
173+
174+
deploy-runtime:
175+
needs: [deploy-gdal]
176+
if: contains(github.ref, 'tags') && github.event_name == 'push'
177+
strategy:
178+
matrix:
179+
runtime: ['3.12', '3.13']
180+
arch: [amd64, arm64]
181+
include:
182+
- arch: amd64
183+
runner: ubuntu-24.04
184+
- arch: arm64
185+
runner: ubuntu-24.04-arm
186+
runs-on: ${{ matrix.runner }}
187+
steps:
188+
- uses: actions/checkout@v6
189+
190+
- name: Set up Docker Buildx
191+
uses: docker/setup-buildx-action@v3
192+
193+
- name: Login to Github
194+
uses: docker/login-action@v3
195+
with:
196+
registry: ghcr.io
197+
username: ${{ github.repository_owner }}
198+
password: ${{ secrets.GITHUB_TOKEN }}
199+
200+
- name: Build and push runtime image (python${{ matrix.runtime }}, ${{ matrix.arch }})
201+
uses: docker/build-push-action@v6
202+
with:
203+
platforms: linux/${{ matrix.arch }}
204+
context: .
205+
file: dockerfiles/runtimes/python
206+
build-args: |
207+
GDAL_VERSION_TAG=${{ env.GDAL_VERSION_TAG }}-${{ matrix.arch }}
208+
RUNTIME_VERSION=${{ matrix.runtime }}
209+
NUMPY_VERSION=2.4.2
210+
PKG_INSTALLER=dnf
211+
push: true
212+
cache-from: type=gha,scope=python${{ matrix.runtime }}-${{ matrix.arch }}
213+
cache-to: type=gha,mode=max,scope=python${{ matrix.runtime }}-${{ matrix.arch }}
214+
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${{ matrix.runtime }}-${{ matrix.arch }}
215+
216+
deploy-runtime-manifest:
217+
needs: [deploy-runtime]
218+
runs-on: ubuntu-24.04
219+
if: contains(github.ref, 'tags') && github.event_name == 'push'
220+
strategy:
221+
matrix:
222+
runtime: ['3.12', '3.13']
223+
steps:
224+
- name: Login to Github
225+
uses: docker/login-action@v3
226+
with:
227+
registry: ghcr.io
228+
username: ${{ github.repository_owner }}
229+
password: ${{ secrets.GITHUB_TOKEN }}
122230

123-
- name: Build Runtime and Push Python >= 3.12 with dnf
231+
- name: Create multi-arch manifest (python${{ matrix.runtime }})
124232
run: |
125-
runtimes='3.12 3.13'
126-
for runtime in ${runtimes}; do
127-
docker build \
128-
--platform=linux/amd64 \
129-
--build-arg GDAL_VERSION_TAG=${{ env.GDAL_VERSION_TAG }} \
130-
--build-arg RUNTIME_VERSION=${runtime} \
131-
--build-arg NUMPY_VERSION=2.4.2 \
132-
--build-arg PKG_INSTALLER=dnf \
133-
-f dockerfiles/runtimes/python \
134-
-t ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${runtime} .
135-
docker push ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${runtime}
136-
done
233+
docker buildx imagetools create \
234+
-t ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${{ matrix.runtime }} \
235+
ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${{ matrix.runtime }}-amd64 \
236+
ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${{ matrix.runtime }}-arm64
137237
138238
update-layer:
139-
needs: [deploy]
140-
runs-on: ubuntu-latest
239+
needs: [deploy-layers]
240+
runs-on: ubuntu-24.04
141241
steps:
142242
- uses: actions/checkout@v6
143243

‎README.md‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Follow the [instruction](https://medium.com/@devlog/gdal-in-aws-lambda-stop-anno
2222

2323
Based on `public.ecr.aws/lambda/provided:al2023` (Amazon Linux 2023)
2424

25+
Images are multi-arch (`linux/amd64` and `linux/arm64`) — Docker pulls the manifest matching your platform automatically.
26+
2527
- GDAL 3.12.2
2628
- **ghcr.io/wongcht/lambda-gdal:3.12** (Feb 2026)
2729

@@ -129,9 +131,12 @@ Starting with gdal3.1 (PROJ 7.1), you can set `PROJ_NETWORK=ON` to use [remote g
129131

130132
# AWS Lambda Layers
131133

132-
| gdal | amazonlinux version | size (Mb) | unzipped size (Mb) | arn |
133-
| ---- | ------------------- | --------- | ------------------ | ----------------------------------------------------------- |
134-
| 3.12 | 5 | TBD | TBD | arn:aws:lambda:{REGION}:959051626939:layer:gdal312:{VERSION} |
134+
Each GDAL version is published as two layers, one per Lambda architecture. Pick the layer matching your function's `Architectures` setting — a layer built for one architecture cannot be attached to a function configured for the other.
135+
136+
| gdal | architecture | amazonlinux version | size (Mb) | unzipped size (Mb) | arn |
137+
| ---- | ------------ | -------------------- | --------- | ------------------- | ----------------------------------------------------------------- |
138+
| 3.12 | x86_64 | 5 | TBD | TBD | arn:aws:lambda:{REGION}:959051626939:layer:gdal312-x86_64:{VERSION} |
139+
| 3.12 | arm64 | 5 | TBD | TBD | arn:aws:lambda:{REGION}:959051626939:layer:gdal312-arm64:{VERSION} |
135140

136141
see [/layer.json](/layer.json) for the list of arns
137142

@@ -143,9 +148,14 @@ cat layer.json| jq '.[] | select(.region == "eu-west-2")'
143148
"region": "eu-west-2",
144149
"layers": [
145150
{
146-
"name": "gdal312",
147-
"arn": "arn:aws:lambda:eu-west-2:959051626939:layer:gdal312:5",
148-
"version": 5
151+
"name": "gdal312-x86_64",
152+
"arn": "arn:aws:lambda:eu-west-2:959051626939:layer:gdal312-x86_64:1",
153+
"version": 1
154+
},
155+
{
156+
"name": "gdal312-arm64",
157+
"arn": "arn:aws:lambda:eu-west-2:959051626939:layer:gdal312-arm64:1",
158+
"version": 1
149159
}
150160
]
151161
}
@@ -202,7 +212,7 @@ package.zip
202212

203213
**AWS Lambda Config:**
204214

205-
- arn: `arn:aws:lambda:us-east-1:959051626939:layer:gdal312:5` (example)
215+
- arn: `arn:aws:lambda:us-east-1:959051626939:layer:gdal312-x86_64:5` (example, use `gdal312-arm64` if your function's **Architectures** is set to `arm64`)
206216
- env:
207217
- **GDAL_DATA:** /opt/share/gdal
208218
- **PROJ_LIB:** /opt/share/proj
@@ -270,7 +280,7 @@ package.zip
270280

271281
**AWS Lambda Config:**
272282

273-
- arn: `arn:aws:lambda:us-east-1:959051626939:layer:gdal312:1` (example)
283+
- arn: `arn:aws:lambda:us-east-1:959051626939:layer:gdal312-x86_64:1` (example, use `gdal312-arm64` if your function's **Architectures** is set to `arm64`)
274284
- env:
275285
- **GDAL_DATA:** /opt/share/gdal
276286
- **PROJ_LIB:** /opt/share/proj

‎scripts/build.sh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ GDAL_VERSION=$1
44
GDAL_VERSION_TAG=${GDAL_VERSION%.*}
55
RUNTIME=$2
66
RUNTIME_VERSION=$3
7+
PLATFORM=${PLATFORM:-linux/amd64}
78

8-
echo "Building image for AWS Lambda | GDAL: ${GDAL_VERSION} | Runtime: ${RUNTIME}:${RUNTIME_VERSION}"
9+
echo "Building image for AWS Lambda | GDAL: ${GDAL_VERSION} | Runtime: ${RUNTIME}:${RUNTIME_VERSION} | Platform: ${PLATFORM}"
910

1011
docker buildx build \
11-
--platform=linux/amd64 \
12+
--platform=${PLATFORM} \
1213
--build-arg GDAL_VERSION=${GDAL_VERSION} \
1314
-f dockerfiles/Dockerfile \
1415
-t ghcr.io/wongcht/lambda-gdal:${GDAL_VERSION_TAG} .
1516

1617
docker buildx build \
17-
--platform=linux/amd64 \
18+
--platform=${PLATFORM} \
1819
--build-arg GDAL_VERSION_TAG=${GDAL_VERSION_TAG} \
1920
--build-arg RUNTIME_VERSION=${RUNTIME_VERSION} \
2021
-f dockerfiles/runtimes/${RUNTIME} \

‎scripts/create-layer.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ cd $PREFIX && zip -r9q --symlinks /tmp/package.zip lib/*.so*
1919
cd $PREFIX && zip -r9q --symlinks /tmp/package.zip share
2020
cd $PREFIX && zip -r9q --symlinks /tmp/package.zip bin/gdal* bin/ogr* bin/geos* bin/nearblack bin/postgres bin/pg_* bin/proj*
2121

22-
cp /tmp/package.zip /local/package.zip
22+
cp /tmp/package.zip /local/${OUTPUT_ZIP:-package.zip}

‎scripts/deploy.py‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,23 @@
4747
@click.command()
4848
@click.argument("gdalversion", type=str)
4949
@click.option("--deploy", is_flag=True)
50-
def main(gdalversion, deploy):
50+
@click.option(
51+
"--arch",
52+
type=click.Choice(["x86_64", "arm64"]),
53+
default="x86_64",
54+
help="Target Lambda architecture for this layer.",
55+
)
56+
@click.option(
57+
"--package",
58+
type=str,
59+
default="package.zip",
60+
help="Path to the layer zip built for --arch.",
61+
)
62+
def main(gdalversion, deploy, arch, package):
5163
"""Build and Deploy Layers."""
5264
gdalversion_nodot = gdalversion.replace(".", "")
53-
layer_name = f"gdal{gdalversion_nodot}"
54-
description = f"Lambda Layer with GDAL{gdalversion} for Amazon Linux 2023"
65+
layer_name = f"gdal{gdalversion_nodot}-{arch}"
66+
description = f"Lambda Layer with GDAL{gdalversion} for Amazon Linux 2023 ({arch})"
5567

5668
if deploy:
5769
session = boto3_session()
@@ -65,11 +77,12 @@ def main(gdalversion, deploy):
6577
client = session.client("lambda", region_name=region, config=config)
6678

6779
click.echo("Publishing new version", err=True)
68-
with open("package.zip", "rb") as zf:
80+
with open(package, "rb") as zf:
6981
res = client.publish_layer_version(
7082
LayerName=layer_name,
7183
Content={"ZipFile": zf.read()},
7284
CompatibleRuntimes=CompatibleRuntimes_al2023,
85+
CompatibleArchitectures=[arch],
7386
Description=description,
7487
LicenseInfo="MIT",
7588
)

‎scripts/list.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
# "gdal33-al2", # archive
3131
# "gdal35", # archive
3232
# "gdal36", # archive
33-
"gdal312",
33+
"gdal312-x86_64",
34+
"gdal312-arm64",
3435
]
3536

3637

0 commit comments

Comments
 (0)