-
Notifications
You must be signed in to change notification settings - Fork 40
211 lines (181 loc) · 8.26 KB
/
publish-docker-image.yml
File metadata and controls
211 lines (181 loc) · 8.26 KB
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
202
203
204
205
206
207
208
209
210
211
name: Release multi-arch Docker Image
on:
release:
types: [ published ]
env:
IMAGE_REPOSITORY: testcontainers/ryuk
jobs:
release-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: linux/Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v6
push: true
tags: |
${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-linux
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-linux
outputs: type=image,compression=uncompressed
release-windows:
strategy:
matrix:
os-version:
- ltsc2019
- ltsc2022
runs-on: windows-2022
steps:
- uses: actions/checkout@v5
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker info
run: docker info
- name: Build image
run: |
docker build -f windows/Dockerfile --build-arg BASE_IMAGE=mcr.microsoft.com/windows/nanoserver:${{ matrix.os-version }} `
-t ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-windows.${{ matrix.os-version }} `
-t ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-windows.${{ matrix.os-version }} .
- name: Push image
run: |
docker push ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-windows.${{ matrix.os-version }}
docker push ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-windows.${{ matrix.os-version }}
release:
needs:
- release-linux
- release-windows
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect
- name: Get os version for nanoserver:ltsc2019
run: >-
full_version=$(docker manifest inspect mcr.microsoft.com/windows/nanoserver:ltsc2019 | jq -r '.manifests[]|.platform|."os.version"'| sed 's@.*:@@') || true;
echo "OS_VERSION_ltsc2019=${full_version}" >> $GITHUB_ENV;
- name: Get os version for nanoserver:ltsc2022
run: >-
full_version=$(docker manifest inspect mcr.microsoft.com/windows/nanoserver:ltsc2022 | jq -r '.manifests[]|.platform|."os.version"'| sed 's@.*:@@') || true;
echo "OS_VERSION_ltsc2022=${full_version}" >> $GITHUB_ENV;
- name: Docker Manifest to Docker Hub
run: >-
target_image=${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }};
linux_manifest=$(docker manifest inspect ${target_image}-linux);
linux_digests=$(docker manifest inspect ${target_image}-linux | jq -r '.manifests[].digest');
manifest_list=${linux_digests//sha256:/${target_image%%:*}@sha256:};
manifest_list+=" ${target_image}-windows.ltsc2019";
manifest_list+=" ${target_image}-windows.ltsc2022";
docker manifest create ${target_image} ${manifest_list};
docker manifest annotate \
--os-version ${OS_VERSION_ltsc2019} \
--os windows \
--arch amd64 \
${target_image} "${target_image}-windows.ltsc2019";
docker manifest annotate \
--os-version ${OS_VERSION_ltsc2022} \
--os windows \
--arch amd64 \
${target_image} "${target_image}-windows.ltsc2022";
docker manifest push ${target_image};
- name: Docker Manifest to Github Container Registry
run: >-
target_image=ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }};
linux_manifest=$(docker manifest inspect ${target_image}-linux);
linux_digests=$(docker manifest inspect ${target_image}-linux | jq -r '.manifests[].digest');
manifest_list=${linux_digests//sha256:/${target_image%%:*}@sha256:};
manifest_list+=" ${target_image}-windows.ltsc2019";
manifest_list+=" ${target_image}-windows.ltsc2022";
docker manifest create ${target_image} ${manifest_list};
docker manifest annotate \
--os-version ${OS_VERSION_ltsc2019} \
--os windows \
--arch amd64 \
${target_image} "${target_image}-windows.ltsc2019";
docker manifest annotate \
--os-version ${OS_VERSION_ltsc2022} \
--os windows \
--arch amd64 \
${target_image} "${target_image}-windows.ltsc2022";
docker manifest push ${target_image};
check-release:
runs-on: ubuntu-latest
needs:
- release
steps:
- uses: actions/checkout@v5
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Print multi-arch manifest
run: |
docker manifest inspect --verbose ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }} > manifest_complete_docker.json
cat manifest_complete_docker.json | jq ".[].Descriptor.platform" | jq "(.architecture + \"_\" + .os + \"_\") + .\"os.version\"" | sort | uniq > architectures_actual_docker.txt
docker manifest inspect --verbose ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }} > manifest_complete_ghcr.json
cat manifest_complete_ghcr.json | jq ".[].Descriptor.platform" | jq "(.architecture + \"_\" + .os + \"_\") + .\"os.version\"" | sort | uniq > architectures_actual_ghcr.txt
- name: Check multi-arch manifest
run: |
cat supported-architectures.txt | sort | uniq > architectures_expected.txt
cat architectures_actual_docker.txt
# we're counting the entries only, because windows os.version numbers change too frequently
# exclude manifest entries with "unknown" architectures
diff <(echo "$(cat architectures_expected.txt | wc -l)") <(echo "$(cat architectures_actual_docker.txt | grep -v unknown_unknown_ | wc -l)")
cat architectures_actual_ghcr.txt
# we're counting the entries only, because windows os.version numbers change too frequently
# exclude manifest entries with "unknown" architectures
diff <(echo "$(cat architectures_expected.txt | wc -l)") <(echo "$(cat architectures_actual_ghcr.txt | grep -v unknown_unknown_ | wc -l)")