-
Notifications
You must be signed in to change notification settings - Fork 3
201 lines (198 loc) · 7.77 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
---
name: build
on:
push:
paths:
- .github/workflows/build.yml
- Dockerfile.alpine
- Dockerfile.debian
- Dockerfile.redhat
pull_request:
paths:
- .github/workflows/build.yml
- Dockerfile.alpine
- Dockerfile.debian
- Dockerfile.redhat
schedule:
- cron: "42 10 * * 1"
jobs:
build:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
name: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
- image: debian:11-slim
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8
- image: debian:12-slim
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: debian:sid-slim
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu:18.04
dockerfile: Dockerfile.debian
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu:20.04
dockerfile: Dockerfile.debian
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu:22.04
dockerfile: Dockerfile.debian
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: ubuntu:24.04
dockerfile: Dockerfile.debian
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: fedora:39
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: fedora:40
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: fedora:41
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: almalinux:8
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: almalinux:9
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
- image: rockylinux:8
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: rockylinux:9
dockerfile: Dockerfile.redhat
platforms: linux/amd64,linux/arm64/v8
- image: alpine:3.17
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine:3.18
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine:3.19
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine:3.20
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
- image: alpine:3.21
dockerfile: Dockerfile.alpine
platforms: linux/amd64,linux/arm64/v8
env:
BASE_IMAGE: ${{ matrix.image }}
DOCKER_DEPLOY_IMAGES: false
steps:
- uses: actions/checkout@v4
- name: Set up env vars
run: |
set -vx
IMG_TMP="${BASE_IMAGE/:/-}"
echo "IMG=${IMG_TMP/-slim}" >>$GITHUB_ENV
echo "REPO=docker-systemd" >>$GITHUB_ENV
# See: https://github.com/actions/runner-images/issues/9425
- name: Patch crun
shell: bash
run: |
curl -Lo ./crun https://github.com/containers/crun/releases/download/1.14.3/crun-1.14.3-linux-amd64
sudo install crun /usr/bin/crun
- name: Install qemu-user-static
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build images
run: |
podman manifest create ${{ env.REPO }}:${{ env.IMG }}
for arch in $(echo ${{ matrix.platforms }} | sed 's/,/ /g'); do
msg="Build $arch:"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
podman buildx build --tag ${{ env.REPO }}:${{ env.IMG }}-${arch//\//-} \
--platform $arch \
--manifest ${{ env.REPO }}:${{ env.IMG }} \
-f ${{ matrix.dockerfile }} \
--build-arg base_image=${{ matrix.image }}
done
podman images
- name: Push images to local registry
run: |
podman manifest push --tls-verify=0 \
--all ${{ env.REPO }}:${{ env.IMG }} \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }}
- name: Systemd check
if: (!contains(matrix.dockerfile, 'alpine'))
run: |
podman run --tls-verify=0 --name sys-test --rm -d \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }}
# debian 9 takes time to boot
if [[ "$BASE_IMAGE" == "debian:9-slim" ]]; then
sleep 100
else
sleep 2
fi
podman exec -it sys-test systemd-analyze
- name: OpenRC check
if: (contains(matrix.dockerfile, 'alpine'))
run: |
podman run --tls-verify=0 --name init-test --rm -d \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }}
podman exec -it init-test rc-status
- name: Check GitHub settings
if: >
(github.event_name == 'push' || github.event_name == 'schedule') &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) &&
github.repository == 'fauust/docker-systemd'
run: |
missing=()
[[ -n "${{ secrets.DOCKER_USER }}" ]] || missing+=(DOCKER_USER)
[[ -n "${{ secrets.DOCKER_TOKEN }}" ]] || missing+=(DOCKER_TOKEN)
for i in "${missing[@]}"; do
echo "Missing github secret: $i"
done
(( ${#missing[@]} == 0 )) || exit 1
echo "DOCKER_DEPLOY_IMAGES=true" >> $GITHUB_ENV
- name: Login to ghcr.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images to ghcr.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
run: |
msg="Push docker image to ghcr.io (${{ env.IMG }})"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }} \
docker://ghcr.io/${{ secrets.DOCKER_USER }}/${{ env.REPO }}:${{ env.IMG }}
- name: Login to docker.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push images to docker.io
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
run: |
msg="Push docker image to docker.io (${{ env.IMG }})"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://localhost:5000/${{ env.REPO }}:${{ env.IMG }} \
docker://docker.io/${{ secrets.DOCKER_USER }}/${{ env.REPO }}:${{ env.IMG }}
- name: Update docker.io description
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
repository: ${{ secrets.DOCKER_USER }}/${{ env.REPO }}
readme-filepath: README.md