Skip to content

Commit

Permalink
Make docker tasks work on Windows (Consensys#7755)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Nov 24, 2023
1 parent 82c578d commit 04759b4
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,10 @@ def dockerImage = "consensys/teku"
def dockerJdkVariants = [ "jdk17" ]
def dockerBuildDir = "build/docker-teku/"

def executableAndArg = System.getProperty('os.name').toLowerCase().contains('windows') ? ["cmd", "/c"] : ["sh", "-c"]

task distDocker {
dependsOn dockerDistUntar

def dockerBuildVersion = 'develop'
doLast {
for (def variant in dockerJdkVariants) {
Expand All @@ -512,14 +513,14 @@ task distDocker {
exec {
def image = "${dockerImage}:${dockerBuildVersion}-${variant}"
workingDir dockerBuildDir
executable "sh"
args "-c", "docker build --pull --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
executable executableAndArg[0]
args executableAndArg[1], "docker build --pull --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
}
}
// tag the "default" (which is the variant in the zero position)
exec {
executable "sh"
args "-c", "docker tag '${dockerImage}:${dockerBuildVersion}-${dockerJdkVariants[0]}' '${dockerImage}:${dockerBuildVersion}'"
executable executableAndArg[0]
args executableAndArg[1], "docker tag ${dockerImage}:${dockerBuildVersion}-${dockerJdkVariants[0]} ${dockerImage}:${dockerBuildVersion}"
}
}
}
Expand Down Expand Up @@ -556,17 +557,17 @@ task uploadDocker {

exec {
workingDir dockerBuildDir
executable "sh"
args "-c", "docker build --pull --platform ${platform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} ${tags} ."
executable executableAndArg[0]
args executableAndArg[1], "docker build --pull --platform ${platform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} ${tags} ."
}

//docker trust sign runs one image at a time, so we have to remove the '-t' in the string and split into a list we can use
def trustTags = tags.replaceAll( '-t ', '' ).trim().split(' ')
for (def t in trustTags) {
exec {
workingDir dockerBuildDir
executable "sh"
args "-c", "docker trust sign ${t} && docker push ${t} "
executable executableAndArg[0]
args executableAndArg[1], "docker trust sign ${t} && docker push ${t} "
}
}
}
Expand Down Expand Up @@ -600,8 +601,8 @@ task manifestDocker {
for (def tag in tags) {
platforms.forEach { platform -> cmd += "${tag}-${platform} " }
exec {
executable "sh"
args "-c", "docker manifest create ${tag} ${cmd} && docker manifest push ${tag}"
executable executableAndArg[0]
args executableAndArg[1], "docker manifest create ${tag} ${cmd} && docker manifest push ${tag}"
}
}
}
Expand Down

0 comments on commit 04759b4

Please sign in to comment.