ci: build release images without a missing Docker daemon

This commit is contained in:
codex 2026-10-03 16:00:22 -05:00
parent 3c0c868708
commit 596b2df8e6

66
Jenkinsfile vendored
View File

@ -18,6 +18,7 @@ spec:
operator: NotIn operator: NotIn
values: values:
- titan-06 - titan-06
- titan-08
preferredDuringSchedulingIgnoredDuringExecution: preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100 - weight: 100
preference: preference:
@ -38,22 +39,22 @@ spec:
jenkins/jenkins-jenkins-agent: "true" jenkins/jenkins-jenkins-agent: "true"
containers: containers:
- name: builder - name: builder
image: registry.bstein.dev/bstein/docker:27 image: gcr.io/kaniko-project/executor@sha256:c3109d5926a997b100c4343944e06c6b30a6804b2f9abe0994d3de6ef92b028e
command: command:
- cat - /busybox/cat
tty: true tty: true
env: resources:
- name: DOCKER_HOST requests:
value: tcp://localhost:2375 cpu: 100m
- name: DOCKER_TLS_CERTDIR memory: 1Gi
value: "" limits:
cpu: 1500m
memory: 2Gi
volumeMounts: volumeMounts:
- name: workspace-volume - name: workspace-volume
mountPath: /home/jenkins/agent mountPath: /home/jenkins/agent
- name: docker-config-writable - name: docker-config-writable
mountPath: /root/.docker mountPath: /kaniko/.docker
- name: harbor-config
mountPath: /docker-config
- name: tester - name: tester
image: registry.bstein.dev/bstein/golang:1.25-bookworm image: registry.bstein.dev/bstein/golang:1.25-bookworm
command: command:
@ -73,12 +74,6 @@ spec:
volumes: volumes:
- name: docker-config-writable - name: docker-config-writable
emptyDir: {} emptyDir: {}
- name: harbor-config
secret:
secretName: harbor-robot-pipeline
items:
- key: .dockerconfigjson
path: config.json
- name: workspace-volume - name: workspace-volume
emptyDir: {} emptyDir: {}
""" """
@ -523,7 +518,7 @@ PY
expression { return params.PUBLISH_IMAGES } expression { return params.PUBLISH_IMAGES }
} }
steps { steps {
container('builder') { container('tester') {
script { script {
sh 'git config --global --add safe.directory /home/jenkins/agent/workspace/Soteria' sh 'git config --global --add safe.directory /home/jenkins/agent/workspace/Soteria'
def semver = sh(returnStdout: true, script: 'git describe --tags --exact-match || true').trim() def semver = sh(returnStdout: true, script: 'git describe --tags --exact-match || true').trim()
@ -536,24 +531,6 @@ PY
} }
} }
} }
stage('Buildx setup') {
when {
expression { return params.PUBLISH_IMAGES }
}
steps {
container('builder') {
sh '''
set -eu
seq 1 10 | while read _; do
docker info && break || sleep 2
done
BUILDER_NAME="soteria-${BUILD_NUMBER}"
docker buildx rm "${BUILDER_NAME}" >/dev/null 2>&1 || true
docker buildx create --name "${BUILDER_NAME}" --driver docker-container --driver-opt image=registry.bstein.dev/bstein/buildkit:buildx-stable-1 --bootstrap --use
'''
}
}
}
stage('Build & push image') { stage('Build & push image') {
when { when {
expression { return params.PUBLISH_IMAGES } expression { return params.PUBLISH_IMAGES }
@ -563,13 +540,20 @@ PY
withCredentials([usernamePassword(credentialsId: 'harbor-robot', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) { withCredentials([usernamePassword(credentialsId: 'harbor-robot', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) {
sh ''' sh '''
set -eu set -eu
set +x
VERSION_TAG=$(cut -d= -f2 build.env) VERSION_TAG=$(cut -d= -f2 build.env)
printf '%s' "${HARBOR_PASSWORD}" | docker login registry.bstein.dev -u "${HARBOR_USERNAME}" --password-stdin umask 077
docker buildx build --platform linux/arm64 \ auth=$(printf '%s:%s' "${HARBOR_USERNAME}" "${HARBOR_PASSWORD}" | base64 | tr -d '\\n')
--provenance=false \ printf '{"auths":{"registry.bstein.dev":{"auth":"%s"}}}\\n' "${auth}" > /kaniko/.docker/config.json
--tag registry.bstein.dev/bstein/soteria:${VERSION_TAG} \ trap 'rm -f /kaniko/.docker/config.json' EXIT
--tag registry.bstein.dev/bstein/soteria:latest \ /kaniko/executor \
--push . --context "${WORKSPACE}" \
--dockerfile "${WORKSPACE}/Dockerfile" \
--build-arg BUILDPLATFORM=linux/arm64 \
--build-arg TARGETOS=linux \
--build-arg TARGETARCH=arm64 \
--destination "registry.bstein.dev/bstein/soteria:${VERSION_TAG}" \
--destination registry.bstein.dev/bstein/soteria:latest
''' '''
} }
} }