Skip to content

Commit 0e9c1c7

Browse files
committed
Build arm64 docker images with attestation
Update the CI so that the docker images use provenance attestations for the github container repository. In addition, have the CI generate arm64 images of proj; make both images available through a manifest.
1 parent 5bb60a8 commit 0e9c1c7

File tree

1 file changed

+117
-13
lines changed

1 file changed

+117
-13
lines changed

.github/workflows/docker.yml

Lines changed: 117 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
paths-ignore:
66
- 'docs/**'
7+
branches-ignore: ["dependabot/**"]
78
pull_request:
89
paths-ignore:
910
- 'docs/**'
@@ -21,17 +22,17 @@ permissions:
2122
#
2223
jobs:
2324
containers:
24-
name: ${{ matrix.container }} Container
25-
runs-on: ubuntu-latest
25+
name: ${{ matrix.container }} Container - ${{ matrix.runner }}
2626
strategy:
2727
matrix:
28-
container: ["proj","proj-docs"]
29-
dockerfile: ["./Dockerfile", "./docs/docbuild/Dockerfile"]
30-
exclude:
31-
- container: "proj"
32-
dockerfile: "./docs/docbuild/Dockerfile"
28+
container: ["proj"]
29+
runner: [ubuntu-24.04, ubuntu-24.04-arm]
30+
dockerfile: ["./Dockerfile"]
31+
include:
3332
- container: "proj-docs"
34-
dockerfile: "./Dockerfile"
33+
dockerfile: "./docs/docbuild/Dockerfile"
34+
runner: "ubuntu-24.04"
35+
runs-on: ${{ matrix.runner }}
3536
env:
3637
# Only push proj-docs package for master
3738
PUSH_PACKAGES: ${{ github.repository_owner == 'OSGeo' && github.event_name != 'pull_request' && (matrix.container == 'proj' || (matrix.container == 'proj-docs' && github.ref_name == 'master')) }}
@@ -44,24 +45,49 @@ jobs:
4445
echo "are we pushing packages" ${{ env.PUSH_PACKAGES }}
4546
echo "event_name" ${{ github.event_name }}
4647
echo "ref" ${{ github.ref }}
48+
- name: Set up Docker
49+
uses: docker/setup-docker-action@v4
50+
with:
51+
daemon-config: |
52+
{
53+
"debug": false,
54+
"features": {
55+
"containerd-snapshotter": true
56+
}
57+
}
4758
- name: Setup Docker Buildx
4859
id: buildx
4960
uses: docker/setup-buildx-action@v3
5061
with:
5162
version: latest
52-
- if: ${{ env.PUSH_PACKAGES == 'true' }}
53-
name: Login to GitHub Container Registry
63+
64+
- name: Login to GitHub Container Registry
65+
if: env.PUSH_PACKAGES == 'true'
5466
uses: docker/login-action@v3
5567
with:
5668
registry: ghcr.io
5769
username: ${{ github.repository_owner }}
5870
password: ${{ secrets.GHCR_TOKEN }}
59-
- if: ${{ env.PUSH_PACKAGES == 'true' }}
60-
name: Login to Docker Hub
71+
- name: Login to Docker Hub
72+
if: env.PUSH_PACKAGES == 'true'
6173
uses: docker/login-action@v3
6274
with:
6375
username: ${{ secrets.DOCKER_USERNAME }}
6476
password: ${{ secrets.DOCKER_PASSWORD }}
77+
- name: Extract container metadata
78+
id: meta
79+
uses: docker/metadata-action@v5
80+
with:
81+
images: |
82+
ghcr.io/osgeo/${{ matrix.container }}
83+
docker.io/osgeo/${{ matrix.container }}
84+
tags: |
85+
type=ref,event=branch
86+
type=ref,event=pr
87+
type=semver,pattern={{version}}
88+
type=semver,pattern={{major}}.{{minor}}
89+
env:
90+
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
6591
- name: Prepare
6692
id: prep
6793
run: |
@@ -71,8 +97,16 @@ jobs:
7197
fi
7298
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
7399
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
74-
- name: Build image
100+
runner=${{ matrix.runner }}
101+
if [[ "$runner" == *"-arm" ]]; then
102+
ARCH=arm64
103+
else
104+
ARCH=amd64
105+
fi
106+
echo "ARCH=$ARCH" >> $GITHUB_OUTPUT
107+
- name: Build docs image
75108
uses: docker/build-push-action@v6
109+
if: matrix.container == 'proj-docs'
76110
with:
77111
push: ${{ env.PUSH_PACKAGES == 'true' }}
78112
builder: ${{ steps.buildx.outputs.name }}
@@ -92,3 +126,73 @@ jobs:
92126
org.opencontainers.image.revision=${{ github.sha }}
93127
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
94128
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}
129+
- name: Build image
130+
uses: docker/build-push-action@v6
131+
if: matrix.container == 'proj'
132+
with:
133+
push: ${{ env.PUSH_PACKAGES == 'true' }}
134+
builder: ${{ steps.buildx.outputs.name }}
135+
context: .
136+
file: ${{ matrix.dockerfile }}
137+
platforms: linux/${{ steps.prep.outputs.ARCH }}
138+
tags: |
139+
docker.io/osgeo/${{ matrix.container }}:${{ steps.prep.outputs.VERSION }}-${{ steps.prep.outputs.ARCH }}
140+
docker.io/osgeo/${{ matrix.container }}:latest-${{ steps.prep.outputs.ARCH }}
141+
ghcr.io/osgeo/${{ matrix.container }}:${{ steps.prep.outputs.VERSION }}-${{ steps.prep.outputs.ARCH }}
142+
ghcr.io/osgeo/${{ matrix.container }}:latest-${{ steps.prep.outputs.ARCH }}
143+
labels: |
144+
org.opencontainers.image.title=${{ github.event.repository.name }}
145+
org.opencontainers.image.description=${{ github.event.repository.description }}
146+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
147+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
148+
org.opencontainers.image.revision=${{ github.sha }}
149+
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
150+
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}
151+
- name: Generate artifact attestation
152+
if: ${{ env.PUSH_PACKAGES == 'true' && matrix.container == 'proj' }}
153+
uses: actions/attest-build-provenance@v3
154+
with:
155+
subject-name: ghcr.io/osgeo/${{ matrix.container }}
156+
subject-digest: ${{ steps.push.outputs.digest }}
157+
push-to-registry: ${{ env.PUSH_PACKAGES == 'true' }}
158+
159+
create-manifest:
160+
161+
permissions:
162+
contents: read
163+
packages: write
164+
attestations: write
165+
id-token: write
166+
runs-on: ubuntu-latest
167+
env:
168+
PUSH_PACKAGES: ${{ github.repository_owner == 'OSGeo' && github.event_name != 'pull_request' }}
169+
needs: containers
170+
steps:
171+
- name: Login to GitHub Container Registry
172+
uses: docker/login-action@v3
173+
if: env.PUSH_PACKAGES == 'true'
174+
with:
175+
registry: ghcr.io
176+
username: ${{ github.actor }}
177+
password: ${{ secrets.GITHUB_TOKEN }}
178+
179+
- name: Login to Docker Hub
180+
uses: docker/login-action@v3
181+
if: env.PUSH_PACKAGES == 'true'
182+
with:
183+
username: ${{ secrets.DOCKER_USERNAME }}
184+
password: ${{ secrets.DOCKER_PASSWORD }}
185+
186+
- name: Create and push multi-platform manifest
187+
if: env.PUSH_PACKAGES == 'true'
188+
run: |
189+
docker buildx imagetools create \
190+
-t ghcr.io/osgeo/proj:latest \
191+
ghcr.io/osgeo/proj:latest-amd64 \
192+
ghcr.io/osgeo/proj:latest-arm64
193+
194+
docker buildx imagetools create \
195+
-t osgeo/proj:latest \
196+
osgeo/proj:latest-amd64 \
197+
osgeo/proj:latest-arm64
198+

0 commit comments

Comments
 (0)