forked from srl-labs/containerlab
-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (173 loc) · 6.01 KB
/
build-devcontainer.yml
File metadata and controls
187 lines (173 loc) · 6.01 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
name: build-devcontainer
on:
workflow_call:
inputs:
CLAB_VERSION:
description: "Containerlab version"
required: true
type: string
workflow_dispatch:
inputs:
CLAB_VERSION:
description: "Containerlab version"
default: "0.59.0"
required: false
type: string
TAG:
description: "Additional container image tag"
required: false
type: string
# trigger on published release event
# to created the dev container when the packages are published
release:
types:
- published
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
# AMD64 builds
- platform: "linux/amd64"
runner: "ubuntu-24.04"
arch-suffix: "amd64"
variant: "dind"
devContFile: .devcontainer/docker-in-docker/devcontainer.json
image-suffix: "-dind"
- platform: "linux/amd64"
runner: "ubuntu-24.04"
arch-suffix: "amd64"
variant: "dind-slim"
devContFile: .devcontainer/docker-in-docker_slim/devcontainer.json
image-suffix: "-dind-slim"
- platform: "linux/amd64"
runner: "ubuntu-24.04"
arch-suffix: "amd64"
variant: "dood"
devContFile: .devcontainer/docker-outside-of-docker/devcontainer.json
image-suffix: "-dood"
- platform: "linux/amd64"
runner: "ubuntu-24.04"
arch-suffix: "amd64"
variant: "dood-slim"
devContFile: .devcontainer/docker-outside-of-docker_slim/devcontainer.json
image-suffix: "-dood-slim"
# ARM64 builds
- platform: "linux/arm64"
runner: "ubuntu-24.04-arm"
arch-suffix: "arm64"
variant: "dind"
devContFile: .devcontainer/docker-in-docker/devcontainer.json
image-suffix: "-dind"
- platform: "linux/arm64"
runner: "ubuntu-24.04-arm"
arch-suffix: "arm64"
variant: "dind-slim"
devContFile: .devcontainer/docker-in-docker_slim/devcontainer.json
image-suffix: "-dind-slim"
- platform: "linux/arm64"
runner: "ubuntu-24.04-arm"
arch-suffix: "arm64"
variant: "dood"
devContFile: .devcontainer/docker-outside-of-docker/devcontainer.json
image-suffix: "-dood"
- platform: "linux/arm64"
runner: "ubuntu-24.04-arm"
arch-suffix: "arm64"
variant: "dood-slim"
devContFile: .devcontainer/docker-outside-of-docker_slim/devcontainer.json
image-suffix: "-dood-slim"
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
# git short commit
type=sha
# manually set tag
type=raw,value=${{ inputs.tag }}
- name: Extract tags
id: extract-tags
run: |
TAGS=$(echo '${{ steps.meta.outputs.tags }}' | awk -F: '{print $2}' | sed "s/$/\-${{ matrix.arch-suffix }}/" | paste -sd "," -)
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
shell: bash
- name: Build dev container image
uses: devcontainers/ci@v0.3
env:
CLAB_VERSION: ${{ inputs.clab_version }}
with:
imageName: ghcr.io/${{ github.repository }}/devcontainer${{ matrix.image-suffix }}
imageTag: ${{ steps.extract-tags.outputs.tags }}
push: always
platform: ${{ matrix.platform }}
configFile: ${{ matrix.devContFile }}
create-manifest:
needs: build
runs-on: ubuntu-24.04
strategy:
matrix:
variant:
- name: "dind"
image-suffix: "-dind"
- name: "dind-slim"
image-suffix: "-dind-slim"
- name: "dood"
image-suffix: "-dood"
- name: "dood-slim"
image-suffix: "-dood-slim"
steps:
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
# git short commit
type=sha
# manually set tag
type=raw,value=${{ inputs.tag }}
- name: Extract base tags (without arch suffix)
id: extract-tags
run: |
TAGS=$(echo '${{ steps.meta.outputs.tags }}' | awk -F: '{print $2}' | paste -sd "," -)
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
shell: bash
- name: Create and push manifest
run: |
for tag in $(echo "${{ steps.extract-tags.outputs.tags }}" | tr ',' '\n'); do
IMAGE_BASE="ghcr.io/${{ github.repository }}/devcontainer${{ matrix.variant.image-suffix }}"
# Create manifest
docker manifest create "${IMAGE_BASE}:${tag}" \
--amend "${IMAGE_BASE}:${tag}-amd64" \
--amend "${IMAGE_BASE}:${tag}-arm64"
# Push manifest
docker manifest push "${IMAGE_BASE}:${tag}"
done