This is an automated email from the ASF dual-hosted git repository.
shawnallen85 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-dotnet.git
The following commit(s) were added to refs/heads/master by this push:
new 47e85e6 dev/docker xbuild (#89)
47e85e6 is described below
commit 47e85e6dedaf4cc022b2775bff9b41aec98c41a9
Author: Shawn Black <[email protected]>
AuthorDate: Fri Oct 4 17:51:16 2024 +0000
dev/docker xbuild (#89)
* feature: docker buildx support for arm64 and amd64
---
.github/workflows/ci.yaml | 1 +
gradle/docker.gradle | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 7c62158..36ac74c 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -66,6 +66,7 @@ jobs:
- name: Build Runtime
working-directory: runtime
run: |
+ docker buildx create --use
./gradlew distDocker
# Test this repository
diff --git a/gradle/docker.gradle b/gradle/docker.gradle
index 6ad6850..2925875 100644
--- a/gradle/docker.gradle
+++ b/gradle/docker.gradle
@@ -45,8 +45,16 @@ ext {
dockerTimeout = project.hasProperty('dockerTimeout') ?
dockerTimeout.toInteger() : 840
dockerRetries = project.hasProperty('dockerRetries') ?
dockerRetries.toInteger() : 3
dockerBinary = project.hasProperty('dockerBinary') ? [dockerBinary] :
['docker']
- dockerBuildArg = ['build']
+ dockerBuildArg = ['buildx', 'build', '--platform']
}
+
+def dockerArchitecture = System.getProperty("os.arch")
+def dockerArchitectureMapping = [amd64:"linux/amd64", aarch64:"linux/arm64"]
+def dockerPrimaryArchitecture = dockerArchitectureMapping[dockerArchitecture]
+def dockerAllArchitectures = []
+
+dockerArchitectureMapping.each() { k, v -> dockerAllArchitectures << v }
+
ext.dockerTaggedImageName = dockerRegistry + dockerImagePrefix + '/' +
dockerImageName + ':' + dockerImageTag
if(project.hasProperty('dockerHost')) {
@@ -62,7 +70,7 @@ if(project.hasProperty('dockerBuildArgs')) {
task distDocker {
doLast {
def start = new Date()
- def cmd = dockerBinary + dockerBuildArg + ['-t', dockerImageName,
project.buildscript.sourceFile.getParentFile().getAbsolutePath()]
+ def cmd = dockerBinary + dockerBuildArg + dockerPrimaryArchitecture +
['--load', '-t', dockerTaggedImageName,
project.buildscript.sourceFile.getParentFile().getAbsolutePath()]
retry(cmd, dockerRetries, dockerTimeout)
println("Building '${dockerImageName}' took ${TimeCategory.minus(new
Date(), start)}")
}
@@ -79,13 +87,15 @@ task tagImage {
if(major == 1 && minor < 12) {
dockerCmd += ['-f']
}
- retry(dockerBinary + dockerCmd + [dockerImageName,
dockerTaggedImageName], dockerRetries, dockerTimeout)
+ retry(dockerBinary + dockerCmd + [dockerTaggedImageName,
dockerImageName], dockerRetries, dockerTimeout)
}
}
task pushImage {
doLast {
- def cmd = dockerBinary + ['push', dockerTaggedImageName]
+ def output = (dockerRegistry == '') ? '--load' : '--push'
+ def architectures = (dockerRegistry == '') ? dockerPrimaryArchitecture
: dockerAllArchitectures.join(",")
+ def cmd = dockerBinary + dockerBuildArg + architectures + [output,
'-t', dockerTaggedImageName,
project.buildscript.sourceFile.getParentFile().getAbsolutePath()]
retry(cmd, dockerRetries, dockerTimeout)
}
}