Skip to content

Commit 75898dd

Browse files
committed
Build multi-platform Docker images via CI
1 parent 4b2f53d commit 75898dd

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

.github/workflows/release_docker.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Release Docker
2+
# Builds Stormpy and deploys images to Dockerhub
3+
# Build is distributed across multiple runners based on:
4+
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
5+
6+
on:
7+
# needed to trigger the workflow manually
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: 'Docker tag (e.g. 1.1.0 or stable)'
12+
required: true
13+
default: 'x.y.z'
14+
15+
env:
16+
IMAGE: movesrwth/stormpy
17+
# GitHub runners currently have 4 cores
18+
NR_JOBS: "4"
19+
20+
jobs:
21+
build:
22+
name: Build ${{ matrix.image.tag }} on ${{ matrix.platform.name }}
23+
runs-on: ${{ matrix.platform.runner }}
24+
strategy:
25+
matrix:
26+
image:
27+
- {tag: "${{ github.event.inputs.tag }}-debug",
28+
baseImg: "movesrwth/storm:${{ github.event.inputs.tag }}-debug",
29+
file: "Dockerfile",
30+
buildType: "Debug",
31+
setupArgs: "--debug"
32+
}
33+
- {tag: "${{ github.event.inputs.tag }}",
34+
baseImg: "movesrwth/storm:${{ github.event.inputs.tag }}",
35+
file: "Dockerfile",
36+
buildType: "Release",
37+
setupArgs: ""
38+
}
39+
platform:
40+
- {name: linux/amd64, runner: "ubuntu-latest"}
41+
- {name: linux/arm64, runner: "ubuntu-24.04-arm"}
42+
steps:
43+
- name: Git clone
44+
uses: actions/checkout@v4
45+
- name: Prepare
46+
# Sanitize platform name
47+
run: |
48+
platform=${{ matrix.platform.name }}
49+
echo "PLATFORM=${platform//\//-}" >> $GITHUB_ENV
50+
- name: Docker metadata
51+
id: meta
52+
uses: docker/metadata-action@v5
53+
with:
54+
images: ${{ env.IMAGE }}
55+
tags: |
56+
type=raw,${{ matrix.image.tag }}
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
- name: Login to Docker Hub
60+
# Only login if using original repo
61+
if: github.repository_owner == 'moves-rwth'
62+
uses: docker/login-action@v3
63+
with:
64+
username: ${{ secrets.STORM_CI_DOCKER_USERNAME }}
65+
password: ${{ secrets.STORM_CI_DOCKER_TOKEN }}
66+
- name: Build and push by digest
67+
id: build
68+
uses: docker/build-push-action@v6
69+
with:
70+
file: ${{ matrix.image.file }}
71+
# Set build arguments
72+
build-args: |
73+
STORM_BASE=${{ matrix.image.baseImg }}
74+
build_type=${{ matrix.image.buildType }}
75+
setup_targs=${{ matrix.image.setupArgs }}
76+
no_threads=${{ env.NR_JOBS }}
77+
platforms: ${{ matrix.platform.name }}
78+
labels: ${{ steps.meta.outputs.labels }}
79+
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
80+
- name: Export digest
81+
run: |
82+
mkdir -p ${{ runner.temp }}/digests/${{ matrix.image.tag }}
83+
digest="${{ steps.build.outputs.digest }}"
84+
touch "${{ runner.temp }}/digests/${{ matrix.image.tag }}/${digest#sha256:}"
85+
- name: Upload digest
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: ${{ matrix.image.tag }}-digests-${{ env.PLATFORM }}
89+
path: ${{ runner.temp }}/digests/${{ matrix.image.tag }}/*
90+
if-no-files-found: error
91+
retention-days: 1
92+
93+
merge:
94+
name: Merge manifests for ${{ matrix.image.tag }}
95+
runs-on: ubuntu-latest
96+
needs:
97+
- build
98+
strategy:
99+
matrix:
100+
image:
101+
# Must be the same as above
102+
- {tag: "${{ github.event.inputs.tag }}-debug"}
103+
- {tag: "${{ github.event.inputs.tag }}"}
104+
steps:
105+
- name: Download digests
106+
uses: actions/download-artifact@v4
107+
with:
108+
path: ${{ runner.temp }}/digests/${{ matrix.image.tag }}
109+
pattern: ${{ matrix.image.tag }}-digests-*
110+
merge-multiple: true
111+
- name: Set up Docker Buildx
112+
uses: docker/setup-buildx-action@v3
113+
- name: Docker metadata
114+
id: meta
115+
uses: docker/metadata-action@v5
116+
with:
117+
images: ${{ env.IMAGE }}
118+
tags: |
119+
type=raw,${{ matrix.image.tag }}
120+
- name: Login to Docker Hub
121+
# Only login if using original repo
122+
if: github.repository_owner == 'moves-rwth'
123+
uses: docker/login-action@v3
124+
with:
125+
username: ${{ secrets.STORM_CI_DOCKER_USERNAME }}
126+
password: ${{ secrets.STORM_CI_DOCKER_TOKEN }}
127+
- name: Create manifest list and push
128+
working-directory: ${{ runner.temp }}/digests/${{ matrix.image.tag }}
129+
run: |
130+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< '${{ steps.meta.outputs.json}}') \
131+
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
132+
- name: Inspect image
133+
run: |
134+
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)