Skip to content

Commit

Permalink
generated docker bake file
Browse files Browse the repository at this point in the history
  • Loading branch information
smerle33 committed Aug 21, 2023
1 parent a7e7d04 commit 0ca6f4a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion vars/buildDockerAndPublishImage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def call(String imageShortName, Map userConfig=[:]) {

// Retrieve Library's Static File Resources
final String makefileContent = libraryResource 'io/jenkins/infra/docker/Makefile'
final String bakefileContent = libraryResource 'io/jenkins/infra/docker/docker-bake.hcl'
final boolean semVerEnabledOnPrimaryBranch = finalConfig.automaticSemanticVersioning && env.BRANCH_IS_PRIMARY

// Only run 1 build at a time on primary branch to ensure builds won't use the same tag when semantic versionning is activated
Expand Down Expand Up @@ -73,6 +74,8 @@ def call(String imageShortName, Map userConfig=[:]) {
// The makefile to use must come from the pipeline to avoid a nasty user trying to exfiltrate data from the build
// Even though we have mitigation through the multibranch job config allowing to build PRs only from the repository contributors
writeFile file: 'Makefile', text: makefileContent

writeFile file: 'docker-bake.override.hcl', text: bakefileContent
} // stage

// Automatic tagging on principal branch is not enabled by default, show potential next version in PR anyway
Expand Down Expand Up @@ -144,7 +147,15 @@ def call(String imageShortName, Map userConfig=[:]) {
if (finalConfig.dockerBakeFile != '') {
sh 'make buildbake'
} else {
sh 'make build'
if (cstConfigSuffix == "") {
//linux ==> generated docker bake
env.PLATFORMS=finalConfig.platform
env.DOCKER_BAKE_FILE='docker-bake.override.hcl'
sh 'env && make buildbake'
} else {
// still used for windows
sh 'make build'
}
}
} else {
if (finalConfig.dockerBakeFile != '') {
Expand Down

0 comments on commit 0ca6f4a

Please sign in to comment.