Fix multi-arch container build
Some checks failed
ecodash/pipeline/head There was a failure building this commit

This commit is contained in:
MassiveBox 2023-07-22 10:24:01 +02:00
parent 6bfe31de56
commit c650a1fae1
Signed by: massivebox
GPG key ID: 9B74D3A59181947D
2 changed files with 21 additions and 18 deletions

View file

@ -1,7 +1,10 @@
FROM debian:latest FROM debian:latest
WORKDIR /app WORKDIR /app
COPY app app COPY ecodash_arm ecodash_arm
COPY ecodash_x86 ecodash_x86
COPY templates templates COPY templates templates
RUN if [ "$(uname -m)" = "aarch64" ]; then mv ecodash_arm app; rm ecodash_x86; else mv ecodash_x86 app; rm ecodash_arm fi
CMD ["./app"] CMD ["./app"]

34
jenkins/Jenkinsfile vendored
View file

@ -17,25 +17,15 @@ pipeline {
sh 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin' sh 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin'
sh 'go mod tidy' sh 'go mod tidy'
sh 'golangci-lint run' sh 'golangci-lint run'
sh 'env GOOS=linux GOARCH=amd64 go build -o app src/main/main.go' sh 'env GOOS=linux GOARCH=amd64 go build -o ecodash_x86 src/main/main.go'
stash includes: 'app', name: 'ecodash-x86' stash includes: 'ecodash_x86', name: 'ecodash_x86'
sh 'env GOOS=linux GOARCH=arm go build -o app src/main/main.go' sh 'env GOOS=linux GOARCH=arm go build -o ecodash_arm src/main/main.go'
stash includes: 'app', name: 'ecodash-arm' stash includes: 'ecodash_arm', name: 'ecodash_arm'
stash includes: 'jenkins/Dockerfile', name: 'dockerfile' stash includes: 'jenkins/Dockerfile', name: 'dockerfile'
stash includes: 'templates/**', name: 'templates' stash includes: 'templates/**', name: 'templates'
} }
} }
stage('Build x86 container') {
steps {
unstash 'dockerfile'
unstash 'ecodash-x86'
unstash 'templates'
sh 'cp jenkins/Dockerfile ./Dockerfile; docker build -t ecodash .'
}
}
stage('Prepare buildx') { stage('Prepare buildx') {
steps { steps {
sh """ sh """
@ -50,12 +40,22 @@ pipeline {
} }
} }
stage('Build arm container') { stage('Build multi-arch container') {
steps { steps {
unstash 'dockerfile' unstash 'dockerfile'
unstash 'ecodash-arm' unstash 'ecodash_x86'
unstash 'ecodash_arm'
unstash 'templates' unstash 'templates'
sh 'cp jenkins/Dockerfile ./Dockerfile; docker buildx build --platform linux/arm64 -t ecodash .' sh 'cp jenkins/Dockerfile ./Dockerfile; docker buildx build --platform linux/amd64,linux/arm64 -t ecodash .'
}
}
stage('Publish built files') {
steps {
sh 'mv ecodash_x86 ecodash'
archiveArtifacts artifacts: ['templates/**', 'ecodash'] name: 'ecodash-x86'
sh 'mv ecodash_arm ecodash'
archiveArtifacts artifacts: ['templates/**', 'ecodash'] name: 'ecodash-arm'
} }
} }