Skip to content

Commit 3632118

Browse files
authored
Multi-platform Docker images (#226)
2 parents 07873e2 + e79d272 commit 3632118

File tree

5 files changed

+154
-7
lines changed

5 files changed

+154
-7
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
# Set update schedule for GitHub Actions
1+
# Set update schedule for GitHub Actions and Python packages
22

33
version: 2
44
updates:
55

6+
# Check for updates to GitHub Actions every week
67
- package-ecosystem: "github-actions"
78
directory: "/"
89
schedule:
9-
# Check for updates to GitHub Actions every week
1010
interval: "weekly"
1111

12+
# Check for updates to pip packages every week
13+
- package-ecosystem: "pip"
14+
directory: "/"
15+
schedule:
16+
interval: "weekly"

.github/workflows/formatapply.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: apply-code-format
1+
name: Apply code format
22

3-
on: [ workflow_dispatch ]
3+
on:
4+
workflow_dispatch:
45

56
jobs:
67
build:

.github/workflows/formatcheck.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: check-code-format
1+
name: Check code format
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
47

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

binder/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM movesrwth/stormpy:1.9.0
2-
MAINTAINER Matthias Volk <m.volk@tue.nl>
2+
LABEL org.opencontainers.image.authors="dev@stormchecker.org"
33

44

55
##########

0 commit comments

Comments
 (0)