forked from freeleaps/freeleaps-pub
66 lines
2.4 KiB
Plaintext
66 lines
2.4 KiB
Plaintext
pipeline {
|
|
agent {
|
|
label 'jenkins-agent'
|
|
}
|
|
|
|
environment {
|
|
REGISTRY = 'freeleaps.azurecr.io'
|
|
IMAGE_NAME = 'devbox_v3'
|
|
LINUX_ARM64_IMAGE_TAG = 'latest-linux-arm64'
|
|
LINUX_AMD64_IMAGE_TAG = 'latest-linux-amd64'
|
|
}
|
|
stages {
|
|
stage('Checkout Repository') {
|
|
steps {
|
|
checkout([
|
|
$class: 'GitSCM',
|
|
branches: [[name: '*/main']],
|
|
doGenerateSubmoduleConfigurations: false,
|
|
extensions: [],
|
|
userRemoteConfigs: [[
|
|
credentialsId: "git_freeleaps_int",
|
|
url: "https://dev.azure.com/freeleaps/freeleaps-int/_git/freeleaps-int"
|
|
]]
|
|
])
|
|
}
|
|
}
|
|
stage('Docker Login') {
|
|
steps {
|
|
withCredentials([usernamePassword(credentialsId: 'acr_devops_user',
|
|
usernameVariable: 'DOCKER_USERNAME',
|
|
passwordVariable: 'DOCKER_PASSWORD')]) {
|
|
sh "docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} ${REGISTRY}"
|
|
}
|
|
}
|
|
}
|
|
stage('Set up Docker Buildx') {
|
|
steps {
|
|
sh '''
|
|
# Create and use a new buildx builder
|
|
docker buildx rm mybuilder || true
|
|
docker buildx create --name mybuilder --use
|
|
docker buildx inspect --bootstrap
|
|
'''
|
|
}
|
|
}
|
|
stage('Build Multi-Architecture Docker Image') {
|
|
steps {
|
|
dir("${env.WORKSPACE}/devops/devbox.local/") {
|
|
sh "pwd"
|
|
// Build multi-architecture image for amd64 and arm64
|
|
sh "docker buildx build --build-arg ARCH=amd64 --platform linux/amd64 -t ${REGISTRY}/${IMAGE_NAME}:${LINUX_AMD64_IMAGE_TAG} --push ."
|
|
sh "docker buildx build --build-arg ARCH=arm64 --platform linux/arm64 -t ${REGISTRY}/${IMAGE_NAME}:${LINUX_ARM64_IMAGE_TAG} --push ."
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
success {
|
|
echo 'Docker image built and pushed successfully.'
|
|
}
|
|
failure {
|
|
echo 'Pipeline failed. Please check the logs for details.'
|
|
}
|
|
}
|
|
} |