Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
multiarch
mchyzer committed Oct 6, 2023
1 parent 7c4c740 commit 80f7d48
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Jenkinsfile
@@ -12,7 +12,7 @@
* EXERCISE_FOLDERS has the image name and corresponding build folder
**/

TARGET_BRANCH = '202310'
TARGET_BRANCH = '202310-multiarch'

EXERCISE_FOLDERS = [
"base": "base",
@@ -22,11 +22,12 @@ EXERCISE_FOLDERS = [
]

pipeline {
agent any
agent { node { label 'docker-multi-arch' } }
environment {
maintainer = "t"
imagename = 'g'
tag = 'l'
DOCKERHUBPW=credentials('tieradmin-dockerhub-pw')
}
stages {
stage('Setting build context') {
@@ -70,22 +71,32 @@ pipeline {
stage('Build exerciseSets') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-${maintainer}") {
// def tagSet = generateTagSet()
// def builds = build(tagSet)

if(env.BRANCH_NAME == TARGET_BRANCH) {
//builds.each{ k, v -> echo ("push ${k}") } //for local testing
// builds.each{ k, v -> v.push(k) } <- not used anymore

// the following command needs to be run first on a new node, but not after that
// sh 'docker buildx create --use --name multiarch --append'
EXERCISE_FOLDERS.each { exercise, folder ->
def build = docker.build("${maintainer}/${imagename}:${exercise}-${tag}", "--no-cache --pull --build-arg VERSION_TAG=${tag} ${folder}")
build.push("${exercise}-${tag}")
// old non multi-arch way
// def build = docker.build("${maintainer}/${imagename}:${exercise}-${tag}", "--no-cache --pull --build-arg VERSION_TAG=${tag} ${folder}")
// build.push("${exercise}-${tag}")

// switch to buildx, which is not supported by the jenkins docker plugin
sh 'docker buildx inspect --bootstrap'
sh 'docker buildx ls'
sh 'docker login -u tieradmin -p $DOCKERHUBPW'
sh 'docker buildx inspect --bootstrap'
sh 'docker buildx ls'
sh "docker buildx build --platform linux/amd64 -t ${imagename} --build-arg VERSION_TAG=${tag} --load ${folder}"
sh "docker buildx build --platform linux/arm64 -t ${imagename}:arm64 --build-arg VERSION_TAG=${tag} --load ${folder}"
echo "Pushing image ${maintainer}/${imagename}:${exercise}-${tag} to dockerhub..."
sh "docker buildx build --push --platform linux/arm64,linux/amd64 -t ${maintainer}/${imagename}:${exercise}-${tag} --build-arg VERSION_TAG=${tag} ${folder}"
}
} else {
echo "not building images, since the SCM branch is not ${TARGET_BRANCH}"
}
}
}
}
}

0 comments on commit 80f7d48

Please sign in to comment.