Newer
Older
##### Fork of https://github.com/jdrouet/docker-with-buildx -> git.griefed.de -> github.com/Griefed
# Sources, GitHub, GitLab and Mirroring and all that good stuff
Repositories on GitHub are now for issues only. I've set up my own installation of GitLab and moved all my repositories over to [Git.Griefed.de](https://git.griefed.de/users/Griefed/projects). Make sure to check there first for the latest code before opening an issue on GitHub.
For questions, you can always join my [Discord server](https://discord.griefed.de) and talk to me there.
---
# Docker image with buildx pre-installed
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
# Setup
:warning: **Requires CI/CD variable `GITLAB_TOKEN` with personal-access-token (read/write permision to registry and repository).**
:warning: **Requires CI/CD variable `DOCKERHUB_USER` with lowercase username of the Dockerhub repository owner where the image will be pushed to.**
:warning: **Requires CI/CD variable `DOCKERHUB_REPO` with lowercase name of the Dockerhub repository where the image will be pushed to.**
:warning: **Requires CI/CD variable `DOCKERHUB_TOKEN` with personal-access-token to Docherhub.**
Currently it's doing:
- bump up semantic version (major/minor/patch) according commit [prefixes](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type)
- create tag with release version
- create release for new tag
- update [CHANGELOG.md](CHANGELOG.md) with release notes generated from commits
- commit & push all above steps
# Example setup files
## GitLab Runner config.toml
Example config.toml for a GitLab-Runner which works with a dockerized GitLab and multiarch Docker images using buildx:
```toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Runner-One"
url = "https://url.to.your.gitlab"
token = "token_generated_by_runner_registration"
executor = "docker"
environment = ["DOCKER_TLS_CERTDIR="]
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "ubuntu:20.04"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
cache_dir = "/cache"
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
```
## GitLab .gitlab-ci.yml
Example of a GitLab CI comosed of three stages: test, release and build
```yml
stages:
- test
- release
- build
test docker:
stage: test
image: griefed/docker-with-buildx:latest
services:
- name: docker:dind
alias: docker
variables:
project_name: $CI_PROJECT_NAME
SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
before_script:
- docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_TOKEN" docker.io
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --use --name mybuilder
script:
- docker buildx build
--push
--platform linux/amd64,linux/arm/v7,linux/arm64
--tag "$CI_REGISTRY_IMAGE:develop"
--tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop" .
except:
refs:
- tags
variables:
- $CI_COMMIT_TITLE =~ /^RELEASE:.+$/
release:
needs: ['test docker']
stage: release
image: griefed/gitlab-semantic-release:latest
services:
- name: docker:dind
alias: docker
variables:
project_name: $CI_PROJECT_NAME
SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
script:
- npx semantic-release
only:
- master
except:
refs:
- tags
variables:
- $CI_COMMIT_TITLE =~ /^RELEASE:.+$/
build:
stage: build
image: griefed/docker-with-buildx:latest
services:
- name: docker:dind
alias: docker
variables:
project_name: $CI_PROJECT_NAME
SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
before_script:
- docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_TOKEN" docker.io
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --use --name mybuilder
script:
- docker pull "$CI_REGISTRY_IMAGE:develop"
- docker buildx build
--push
--platform linux/amd64,linux/arm/v7,linux/arm64
--cache-from "$CI_REGISTRY_IMAGE:develop"
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
--tag "$CI_REGISTRY_IMAGE:latest"
--tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:$CI_COMMIT_TAG"
--tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:latest" .
only:
- tags
```
## Semantic-Release .releaserc.yml
Example config for changelog, tag and release generating config file using conventional commits.
```yml
branches: ['master','main']
ci: true
debug: true
dryRun: false
tagFormat: '${version}'
# Global plugin options (will be passed to all plugins)
preset: 'conventionalcommits'
gitlabUrl: 'https://url.to.your.gitlab' # your gitlab url
# Responsible for verifying conditions necessary to proceed with the release:
# configuration is correct, authentication token are valid, etc...
verifyConditions:
- '@semantic-release/changelog'
- '@semantic-release/git'
- '@semantic-release/gitlab'
# Responsible for determining the type of the next release (major, minor or patch).
# If multiple plugins with a analyzeCommits step are defined, the release type will be
# the highest one among plugins output.
# Look details at: https://github.com/semantic-release/commit-analyzer#configuration
analyzeCommits:
- path: '@semantic-release/commit-analyzer'
releaseRules:
- breaking: true
release: major
- type: build # Changes that affect the build system or external dependencies
release: patch
- type: chore # Other changes that don't modify src or test files
release: false
- type: ci # Changes to our CI configuration files and scripts
release: false
- type: docs # Documentation only changes
release: false
- type: feat # A new feature
release: minor
- type: fix # A bug fix
release: patch
- type: perf # A code change that improves performance
release: patch
- type: refactor # A code change that neither fixes a bug nor adds a feature
release: false
- type: revert # Reverts a previous commit
release: patch
- type: style # Changes that do not affect the meaning of the code
release: false
- type: test # Adding missing tests or correcting existing tests
release: false
# Responsible for generating the content of the release note.
# If multiple plugins with a generateNotes step are defined,
# the release notes will be the result of the concatenation of each plugin output.
generateNotes:
- path: '@semantic-release/release-notes-generator'
writerOpts:
groupBy: 'type'
commitGroupsSort: 'title'
commitsSort: 'header'
linkCompare: true
linkReferences: true
presetConfig:
types: # looks like it only works with 'conventionalcommits' preset
- type: 'build'
section: '🦊 CI/CD'
hidden: false
- type: 'chore'
section: 'Other'
hidden: false
- type: 'ci'
section: '🦊 CI/CD'
hidden: false
- type: 'docs'
section: '📔 Docs'
hidden: false
- type: 'example'
section: '📝 Examples'
hidden: false
- type: 'feat'
section: '🚀 Features'
hidden: false
- type: 'fix'
section: '🛠 Fixes'
hidden: false
- type: 'perf'
section: '⏩ Performance'
- type: 'refactor'
section: ':scissors: Refactor'
hidden: false
- type: 'revert'
section: '👀 Reverts'
- type: 'style'
section: '💈 Style'
- type: 'test'
section: '🧪 Tests'
hidden: false
# Responsible for preparing the release, for example creating or updating files
# such as package.json, CHANGELOG.md, documentation or compiled assets
# and pushing a commit.
prepare:
# - path: '@semantic-release/exec'
# # Execute shell command to set package version
# cmd: './deployment/version-plaintext-set.sh ${nextRelease.version}'
# - path: '@semantic-release/exec'
# cmd: './deployment/version-oas-set.sh ${nextRelease.version} openapi.yaml'
# - path: '@semantic-release/exec'
# verifyReleaseCmd: "echo ${nextRelease.version} > VERSION.txt"
- path: '@semantic-release/changelog'
# Create or update the changelog file in the local project repository
- path: '@semantic-release/git'
# Push a release commit and tag, including configurable files
message: 'RELEASE: ${nextRelease.version}'
assets: ['CHANGELOG.md']
# Responsible for publishing the release.
publish:
- path: '@semantic-release/gitlab'
# Publish a GitLab release
# (https://docs.gitlab.com/ce/user/project/releases/index.html#add-release-notes-to-git-tags)
success: false
fail: false
```