From a90a57c83edbf418b3b09305140964cf50ea0d82 Mon Sep 17 00:00:00 2001 From: tvallin Date: Fri, 27 Oct 2023 11:10:25 +0200 Subject: [PATCH] Fix dockerFiles in examples Signed-off-by: tvallin --- docs/mp/guides/mp-tutorial.adoc | 23 +++++++++++++------ examples/employee-app/Dockerfile | 15 +++++++++--- .../cdi/datasource-hikaricp/Dockerfile | 15 +++++++++--- .../helidon-quickstart-mp/Dockerfile | 15 +++++++++--- .../helidon-quickstart-mp/Dockerfile.jlink | 13 +++++++++-- .../helidon-quickstart-se/Dockerfile.jlink | 2 +- .../Dockerfile | 15 +++++++++--- .../Dockerfile.jlink | 13 +++++++++-- .../Dockerfile | 2 +- .../Dockerfile.jlink | 2 +- examples/translator-app/backend/Dockerfile | 15 +++++++++--- examples/translator-app/frontend/Dockerfile | 15 +++++++++--- examples/webserver/opentracing/Dockerfile | 15 +++++++++--- 13 files changed, 125 insertions(+), 35 deletions(-) diff --git a/docs/mp/guides/mp-tutorial.adoc b/docs/mp/guides/mp-tutorial.adoc index 6fb22815d07..3e5fa20b056 100644 --- a/docs/mp/guides/mp-tutorial.adoc +++ b/docs/mp/guides/mp-tutorial.adoc @@ -948,7 +948,17 @@ Add a new `Dockerfile` in the project root directory with the following content: [source,bash] .Dockerfile content ---- -FROM maven:3.8.4-openjdk-17-slim as build <1> +FROM container-registry.oracle.com/java/openjdk:21 as build <1> + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ + WORKDIR /helidon ADD pom.xml . @@ -958,13 +968,13 @@ ADD src src RUN mvn package -DskipTests <3> RUN echo "done!" -FROM openjdk:17-jdk-slim <4> +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon -COPY --from=build /helidon/target/helidon-mp-tutorial.jar ./ <5> +COPY --from=build /helidon/target/helidon-mp-tutorial.jar ./ <4> COPY --from=build /helidon/target/libs ./libs -CMD ["java", "-jar", "helidon-mp-tutorial.jar"] <6> +CMD ["java", "-jar", "helidon-mp-tutorial.jar"] <5> EXPOSE 8080 ---- @@ -977,9 +987,8 @@ EXPOSE 8080 builds faster because they will use this cached layer rather than downloading everything again. <3> Add the source code and do the real build. -<4> Start a second stage using a much smaller runtime image. -<5> Copy the binary and libraries from the first stage. -<6> Set the initial command and expose port 8080. +<4> Copy the binary and libraries from the first stage. +<5> Set the initial command and expose port 8080. To create the Docker image, use the following command: diff --git a/examples/employee-app/Dockerfile b/examples/employee-app/Dockerfile index 29b4c387002..17710481a7c 100644 --- a/examples/employee-app/Dockerfile +++ b/examples/employee-app/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2021 Oracle and/or its affiliates. +# Copyright (c) 2019, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.6.3-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon @@ -33,7 +42,7 @@ RUN mvn package -DskipTests RUN echo "done!" # 2nd stage, build the runtime image -FROM openjdk:17-jdk-slim +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon # Copy the binary built in the 1st stage diff --git a/examples/integrations/cdi/datasource-hikaricp/Dockerfile b/examples/integrations/cdi/datasource-hikaricp/Dockerfile index 13dcb075d73..de49c098f2a 100644 --- a/examples/integrations/cdi/datasource-hikaricp/Dockerfile +++ b/examples/integrations/cdi/datasource-hikaricp/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2021 Oracle and/or its affiliates. +# Copyright (c) 2018, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.6.3-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon @@ -32,7 +41,7 @@ RUN mvn package -DskipTests RUN echo "done!" # 2nd stage, build the runtime image -FROM openjdk:17-jdk-slim +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon # Copy the binary built in the 1st stage diff --git a/examples/quickstarts/helidon-quickstart-mp/Dockerfile b/examples/quickstarts/helidon-quickstart-mp/Dockerfile index e7a36c50829..d2466ddbac5 100644 --- a/examples/quickstarts/helidon-quickstart-mp/Dockerfile +++ b/examples/quickstarts/helidon-quickstart-mp/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2022 Oracle and/or its affiliates. +# Copyright (c) 2018, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.8.4-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon @@ -32,7 +41,7 @@ RUN mvn package -DskipTests RUN echo "done!" # 2nd stage, build the runtime image -FROM openjdk:17-jdk-slim +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon # Copy the binary built in the 1st stage diff --git a/examples/quickstarts/helidon-quickstart-mp/Dockerfile.jlink b/examples/quickstarts/helidon-quickstart-mp/Dockerfile.jlink index 1f0bc842fdc..cc482519f6d 100644 --- a/examples/quickstarts/helidon-quickstart-mp/Dockerfile.jlink +++ b/examples/quickstarts/helidon-quickstart-mp/Dockerfile.jlink @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2022 Oracle and/or its affiliates. +# Copyright (c) 2020, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.8.4-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon diff --git a/examples/quickstarts/helidon-quickstart-se/Dockerfile.jlink b/examples/quickstarts/helidon-quickstart-se/Dockerfile.jlink index 7906e826c2f..245e889702c 100644 --- a/examples/quickstarts/helidon-quickstart-se/Dockerfile.jlink +++ b/examples/quickstarts/helidon-quickstart-se/Dockerfile.jlink @@ -15,7 +15,7 @@ # # 1st stage, build the app -FROM container-registry.oracle.com/java/openjdk:21 as maven +FROM container-registry.oracle.com/java/openjdk:21 as build # Install maven WORKDIR /usr/share diff --git a/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile b/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile index b3ca729710f..0e6c1e2c6b6 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile +++ b/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2022 Oracle and/or its affiliates. +# Copyright (c) 2018, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.8.4-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon @@ -32,7 +41,7 @@ RUN mvn package -DskipTests RUN echo "done!" # 2nd stage, build the runtime image -FROM openjdk:17-jdk-slim +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon # Copy the binary built in the 1st stage diff --git a/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.jlink b/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.jlink index 1f0bc842fdc..cc482519f6d 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.jlink +++ b/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.jlink @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2022 Oracle and/or its affiliates. +# Copyright (c) 2020, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.8.4-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon diff --git a/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile b/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile index 14333cfde36..28188f2b5bc 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile +++ b/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile @@ -15,7 +15,7 @@ # # 1st stage, build the app -FROM container-registry.oracle.com/java/openjdk:21 as maven +FROM container-registry.oracle.com/java/openjdk:21 as build # Install maven WORKDIR /usr/share diff --git a/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.jlink b/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.jlink index 7906e826c2f..245e889702c 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.jlink +++ b/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.jlink @@ -15,7 +15,7 @@ # # 1st stage, build the app -FROM container-registry.oracle.com/java/openjdk:21 as maven +FROM container-registry.oracle.com/java/openjdk:21 as build # Install maven WORKDIR /usr/share diff --git a/examples/translator-app/backend/Dockerfile b/examples/translator-app/backend/Dockerfile index fd93dab3215..41e657aed92 100644 --- a/examples/translator-app/backend/Dockerfile +++ b/examples/translator-app/backend/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2021 Oracle and/or its affiliates. +# Copyright (c) 2018, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.6.3-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon @@ -33,7 +42,7 @@ RUN mvn package -DskipTests RUN echo "done!" # 2nd stage, build the runtime image -FROM openjdk:17-jdk-slim +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon # Copy the binary built in the 1st stage diff --git a/examples/translator-app/frontend/Dockerfile b/examples/translator-app/frontend/Dockerfile index c539e9f9469..9d233504060 100644 --- a/examples/translator-app/frontend/Dockerfile +++ b/examples/translator-app/frontend/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2021 Oracle and/or its affiliates. +# Copyright (c) 2018, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.6.3-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon @@ -33,7 +42,7 @@ RUN mvn package -Dmaven.test.skip RUN echo "done!" # 2nd stage, build the runtime image -FROM openjdk:17-jdk-slim +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon # Copy the binary built in the 1st stage diff --git a/examples/webserver/opentracing/Dockerfile b/examples/webserver/opentracing/Dockerfile index dccd442f15b..47a15766dc9 100644 --- a/examples/webserver/opentracing/Dockerfile +++ b/examples/webserver/opentracing/Dockerfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2021 Oracle and/or its affiliates. +# Copyright (c) 2018, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,16 @@ # # 1st stage, build the app -FROM maven:3.6.3-openjdk-17-slim as build +FROM container-registry.oracle.com/java/openjdk:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ WORKDIR /helidon @@ -33,7 +42,7 @@ RUN mvn package -DskipTests RUN echo "done!" # 2nd stage, build the runtime image -FROM openjdk:17-jdk-slim +FROM container-registry.oracle.com/java/openjdk:21 WORKDIR /helidon # Copy the binary built in the 1st stage