Skip to content

Commit c24bef2

Browse files
chore: use TOML config with buildx to avoid DockerHub rate limits (#2002)
* fix: use TOML config with buildx to avoid DockerHub rate limits * empty commit to trigger a new build (the fourth one seems stuck) * 2 distinct sh calls Co-authored-by: Damien Duportal <damien.duportal@gmail.com> --------- Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
1 parent 0f911e9 commit c24bef2

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Jenkinsfile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ stage('Build') {
158158
stage('Multi arch build') {
159159
infra.withDockerCredentials {
160160
sh '''
161-
docker buildx create --use
162-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
161+
make docker-init
163162
docker buildx bake --file docker-bake.hcl linux
164163
'''
165164
}
@@ -182,11 +181,8 @@ stage('Build') {
182181
// Publication is enabled by default, disabled when simulating a LTS
183182
if (env.PUBLISH == 'true') {
184183
infra.withDockerCredentials {
185-
sh '''
186-
docker buildx create --use
187-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
188-
make publish
189-
'''
184+
sh 'make docker-init'
185+
sh 'make publish'
190186
}
191187
}
192188
}

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ check-reqs:
3939
@$(call check_cli,curl)
4040
@$(call check_cli,jq)
4141

42+
## This function is specific to Jenkins infrastructure and isn't required in other contexts
43+
docker-init: check-reqs
44+
ifeq ($(CI),true)
45+
ifeq ($(wildcard /etc/buildkitd.toml),)
46+
echo 'WARNING: /etc/buildkitd.toml not found, using default configuration.'
47+
docker buildx create --use --bootstrap --driver docker-container
48+
else
49+
docker buildx create --use --bootstrap --driver docker-container --config /etc/buildkitd.toml
50+
endif
51+
else
52+
docker buildx create --use --bootstrap --driver docker-container
53+
endif
54+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
55+
4256
hadolint:
4357
find . -type f -name 'Dockerfile*' -not -path "./bats/*" -print0 | xargs -0 $(ROOT_DIR)/tools/hadolint
4458

0 commit comments

Comments
 (0)