Skip to content

Commit

Permalink
converting to use multi-arch steps
Browse files Browse the repository at this point in the history
  • Loading branch information
chubing authored Sep 29, 2023
1 parent 7c4c740 commit 5c8a3b7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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') {
Expand Down Expand Up @@ -79,8 +80,18 @@ pipeline {
// builds.each{ k, v -> v.push(k) } <- not used anymore

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 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 GROUPER_CONTAINER_VERSION=${tag} --load ${folder}"
sh "docker buildx build --platform linux/arm64 -t ${imagename}:arm64 --build-arg GROUPER_CONTAINER_VERSION=${tag} --load ${folder}"
echo "Pushing image to dockerhub..."
sh "docker buildx build --push --platform linux/arm64,linux/amd64 -t ${maintainer}/${imagename}:${tag} ${folder}"
}
} else {
echo "not building images, since the SCM branch is not ${TARGET_BRANCH}"
Expand Down

0 comments on commit 5c8a3b7

Please sign in to comment.