From b6f5c6f33f1c8a6c2768e0574131376095aa55ae Mon Sep 17 00:00:00 2001 From: ragsns Date: Thu, 2 Nov 2023 09:47:03 -0400 Subject: [PATCH 1/4] multi arch images --- docker-spring-boot/Dockerfile | 4 ++-- docker-spring-boot/readme.md | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docker-spring-boot/Dockerfile b/docker-spring-boot/Dockerfile index fe5b723..cd9fd99 100644 --- a/docker-spring-boot/Dockerfile +++ b/docker-spring-boot/Dockerfile @@ -2,7 +2,7 @@ # FROM openjdk:8-jdk-alpine # For Java 11, try this -FROM adoptopenjdk/openjdk11:alpine-jre +FROM adoptopenjdk/openjdk11 # Refer to Maven build -> finalName ARG JAR_FILE=target/spring-boot-web.jar @@ -18,4 +18,4 @@ ENTRYPOINT ["java","-jar","app.jar"] ## sudo docker run -p 8080:8080 -t docker-spring-boot:1.0 ## sudo docker run -p 80:8080 -t docker-spring-boot:1.0 -## sudo docker run -p 443:8443 -t docker-spring-boot:1.0 \ No newline at end of file +## sudo docker run -p 443:8443 -t docker-spring-boot:1.0 diff --git a/docker-spring-boot/readme.md b/docker-spring-boot/readme.md index 02c54e4..44cbb8e 100644 --- a/docker-spring-boot/readme.md +++ b/docker-spring-boot/readme.md @@ -11,8 +11,11 @@ Tested with For explanation, please visit this article - [Docker and Spring Boot](https://mkyong.com/docker/docker-spring-boot-examples/) ## How to run this? +## make sure DOCKER_DEFAULT_PLATFORM is not set ```bash -$ git clone https://github.com/mkyong/docker-java +$ sdk install java 11.0.20-amzn +$ export DOCKER_DEFAULT_PLATFORM= +$ git clone https://github.com/ragsns/docker-java $ cd docker-spring-boot $ mvn clean package $ java -jar target/spring-boot-web.jar @@ -23,8 +26,12 @@ $ java -jar target/spring-boot-web.jar // create a docker image $ sudo docker build -t spring-boot:1.0 . +// for multi-arch +$ docker buildx build --no-cache \ +--push \ +--platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag ragsns/spring-boot-multi . // run it $ sudo docker run -d -p 8080:8080 -t spring-boot:1.0 access http://localhost:8080 -``` \ No newline at end of file +``` From db5b3e80ad8ad9b808e07299345f187ff1ed1cba Mon Sep 17 00:00:00 2001 From: Rags Date: Thu, 2 Nov 2023 14:27:38 +0000 Subject: [PATCH 2/4] gitpod instructions --- docker-spring-boot/readme.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker-spring-boot/readme.md b/docker-spring-boot/readme.md index 44cbb8e..ecf5853 100644 --- a/docker-spring-boot/readme.md +++ b/docker-spring-boot/readme.md @@ -13,7 +13,7 @@ For explanation, please visit this article - [Docker and Spring Boot](https://mk ## How to run this? ## make sure DOCKER_DEFAULT_PLATFORM is not set ```bash -$ sdk install java 11.0.20-amzn +$ $ export DOCKER_DEFAULT_PLATFORM= $ git clone https://github.com/ragsns/docker-java $ cd docker-spring-boot @@ -27,6 +27,11 @@ $ java -jar target/spring-boot-web.jar // create a docker image $ sudo docker build -t spring-boot:1.0 . // for multi-arch +// if necessary install buildx as below on gitpod +// from https://github.com/docker/buildx/releases/tag/v0.11.2 +$ cp buildx-v0.11.2.darwin-amd64 $_ +$ docker login // login to docker or any other registry +$ docker buildx create --name mybuilder --use --bootstrap // one time only $ docker buildx build --no-cache \ --push \ --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag ragsns/spring-boot-multi . From 3c7fba3356a8cfc64ea3c981967746d20b92bbbb Mon Sep 17 00:00:00 2001 From: Rags Date: Fri, 3 Nov 2023 13:14:22 +0000 Subject: [PATCH 3/4] sdk install added --- docker-spring-boot/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-spring-boot/readme.md b/docker-spring-boot/readme.md index ecf5853..c5c751b 100644 --- a/docker-spring-boot/readme.md +++ b/docker-spring-boot/readme.md @@ -16,6 +16,7 @@ For explanation, please visit this article - [Docker and Spring Boot](https://mk $ $ export DOCKER_DEFAULT_PLATFORM= $ git clone https://github.com/ragsns/docker-java +$ sdk install java 11.0.21-amzn // make it default $ cd docker-spring-boot $ mvn clean package $ java -jar target/spring-boot-web.jar From 437462805da8f089ec5562ed2607ea02fbc9407a Mon Sep 17 00:00:00 2001 From: Rags Date: Fri, 3 Nov 2023 13:49:44 +0000 Subject: [PATCH 4/4] fixed typos --- docker-spring-boot/readme.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker-spring-boot/readme.md b/docker-spring-boot/readme.md index c5c751b..d3f5e78 100644 --- a/docker-spring-boot/readme.md +++ b/docker-spring-boot/readme.md @@ -30,11 +30,13 @@ $ sudo docker build -t spring-boot:1.0 . // for multi-arch // if necessary install buildx as below on gitpod // from https://github.com/docker/buildx/releases/tag/v0.11.2 -$ cp buildx-v0.11.2.darwin-amd64 $_ +// or as below +$ cp buildx-v0.11.2.darwin-amd64 $ docker login // login to docker or any other registry +$ docker buildx bake "https://github.com/docker/buildx.git" $ docker buildx create --name mybuilder --use --bootstrap // one time only $ docker buildx build --no-cache \ ---push \ +--push \ --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag ragsns/spring-boot-multi . // run it $ sudo docker run -d -p 8080:8080 -t spring-boot:1.0