Skip to content

Commit

Permalink
fix: implement docker calls as make targets
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeurherve committed Jun 23, 2024
1 parent 57d5a57 commit f96d882
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
13 changes: 3 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ pipeline {
environment name: 'IMAGE_TYPE', value: 'linux'
}
steps {
sh '''
docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
'''
sh 'make docker-init'
}
}
stage('Build and Test') {
Expand All @@ -61,7 +58,7 @@ pipeline {
sh './build.sh'
sh './build.sh test'
// If the tests are passing for Linux AMD64, then we can build all the CPU architectures
sh 'docker buildx bake --file docker-bake.hcl linux'
sh 'make every-build'
} else {
powershell '& ./build.ps1 test'
}
Expand All @@ -87,11 +84,7 @@ pipeline {
// This function is defined in the jenkins-infra/pipeline-library
infra.withDockerCredentials {
if (isUnix()) {
sh """
docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
./build.sh -r ${remotingVersion} -b ${buildNumber} -d publish
"""
sh "./build.sh -r ${remotingVersion} -b ${buildNumber} -d publish"
} else {
powershell "& ./build.ps1 -RemotingVersion $remotingVersion -BuildNumber $buildNumber -DisableEnvProps publish"
}
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ check_cli = type "$(1)" >/dev/null 2>&1 || { echo "Error: command '$(1)' require
check_image = make --silent list | grep -w '$(1)' >/dev/null 2>&1 || { echo "Error: the image '$(1)' does not exist in manifest for the platform 'linux/$(ARCH)'. Please check the output of 'make list'. Exiting." ; exit 1 ; }
## Base "docker buildx base" command to be reused everywhere
bake_base_cli := docker buildx bake -f docker-bake.hcl --load
bake_base_cli := docker buildx bake --file docker-bake.hcl
bake_cli := $(bake_base_cli) --load

.PHONY: build
.PHONY: test test-alpine test-archlinux test-debian test-jdk11 test-jdk11-alpine
Expand All @@ -31,16 +33,24 @@ check-reqs:
@$(call check_cli,curl)
@$(call check_cli,jq)

## This function is specific to Jenkins infrastructure and isn't required in other contexts
docker-init: check-reqs
@set -x; docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

build: check-reqs
@set -x; $(bake_base_cli) --set '*.platform=linux/$(ARCH)' $(shell make --silent list)
@set -x; $(bake_cli) --set '*.platform=linux/$(ARCH)' $(shell make --silent list)

build-%:
@$(call check_image,$*)
@echo "== building $*"
@set -x; $(bake_base_cli) --set '*.platform=linux/$(ARCH)' '$*'
@set -x; $(bake_cli) --set '*.platform=linux/$(ARCH)' '$*'

every-build: check-reqs
@set -x; $(bake_base_cli) linux

show:
@$(bake_base_cli) linux --print
@$(bake_cli) linux --print

list: check-reqs
@set -x; make --silent show | jq -r '.target | path(.. | select(.platforms[] | contains("linux/$(ARCH)"))?) | add'
Expand Down

0 comments on commit f96d882

Please sign in to comment.