From a9d783192bbe1d6b9cd0cdbf7944d1d9b6cf0645 Mon Sep 17 00:00:00 2001 From: Anatoliy Sablin Date: Sun, 31 May 2020 22:09:53 +0300 Subject: [PATCH] Add multiple-platform builds. Add experimental arm64 build. --- DockerfileX | 16 ++++++++++++++++ build.gradle | 33 +++++++++++++++++++++++++++++++++ docs/build.md | 10 ++++++++++ 3 files changed, 59 insertions(+) create mode 100644 DockerfileX diff --git a/DockerfileX b/DockerfileX new file mode 100644 index 0000000..1e90969 --- /dev/null +++ b/DockerfileX @@ -0,0 +1,16 @@ +FROM --platform=$BUILDPLATFORM openjdk:11.0.7-jre-slim + +VOLUME /etc/ma1sd +VOLUME /var/ma1sd +EXPOSE 8090 + +ENV JAVA_OPTS="" +ENV CONF_FILE_PATH="/etc/ma1sd/ma1sd.yaml" +ENV SIGN_KEY_PATH="/var/ma1sd/sign.key" +ENV SQLITE_DATABASE_PATH="/var/ma1sd/ma1sd.db" + +CMD [ "/start.sh" ] + +ADD src/docker/start.sh /start.sh +ADD src/script/ma1sd /app/ma1sd +ADD build/libs/ma1sd.jar /app/ma1sd.jar diff --git a/build.gradle b/build.gradle index 04eb442..fa081b2 100644 --- a/build.gradle +++ b/build.gradle @@ -274,6 +274,27 @@ task dockerBuild(type: Exec, dependsOn: shadowJar) { } } +task dockerBuildX(type: Exec, dependsOn: shadowJar) { + commandLine 'docker', 'buildx', 'build', '--load', '--platform', 'linux/arm64', '-t', dockerImageTag + '-arm64', project.rootDir + doLast { + exec { + commandLine 'docker', 'buildx', 'build', '--load', '--platform', 'linux/amd64', '-t', dockerImageTag + '-amd64', project.rootDir + } + + exec { + commandLine 'docker', 'tag', dockerImageTag + '-arm64', "${dockerImageName}:latest-arm64-dev" + } + + exec { + commandLine 'docker', 'tag', dockerImageTag + '-amd64', "${dockerImageName}:latest-amd64-dev" + } + + exec { + commandLine 'docker', 'tag', dockerImageTag + '-amd64', "${dockerImageName}:latest-dev" + } + } +} + task dockerPush(type: Exec) { commandLine 'docker', 'push', dockerImageTag @@ -283,3 +304,15 @@ task dockerPush(type: Exec) { } } } + +task dockerPushX(type: Exec) { + commandLine 'docker', 'push', dockerImageTag + + doLast { + exec { + commandLine 'docker', 'push', "${dockerImageName}:latest-dev" + commandLine 'docker', 'push', "${dockerImageName}:latest-amd64-dev" + commandLine 'docker', 'push', "${dockerImageName}:latest-arm64-dev" + } + } +} diff --git a/docs/build.md b/docs/build.md index 8a78284..46f431c 100644 --- a/docs/build.md +++ b/docs/build.md @@ -9,6 +9,8 @@ ## Binaries ### Requirements - JDK 1.8 +- OpenJDK 11 +- OpenJDK 14 ### Build ```bash @@ -70,5 +72,13 @@ Then follow the instruction in the [Debian package](install/debian.md) document. ``` Then follow the instructions in the [Docker install](install/docker.md#configure) document. +### Multi-platform builds + +Provided with experimental docker feature [buildx](https://docs.docker.com/buildx/working-with-buildx/) +To build the arm64 and amd64 images run: +```bash +./gradlew dockerBuildX +``` + ## Next steps - [Integrate with your infrastructure](getting-started.md#integrate)