2.0 update example Dockerfiles (#1706)

* Make sure example Dockerfiles build with maven:3.6-jdk-11 and run with openjdk:11-jre-slim
* Remove main class from stand-alone MP quickstart
This commit is contained in:
Joe DiPol
2020-04-30 08:06:53 -07:00
committed by GitHub
parent 5be6b5e475
commit 7fee208746
19 changed files with 57 additions and 125 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2019, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -33,13 +33,13 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
COPY --from=build /helidon/target/helidon-examples-employee-app ./
COPY --from=build /helidon/target/helidon-examples-employee-app.jar ./
COPY --from=build /helidon/target/libs ./libs
CMD ["java", "-jar", "helidon-examples-employee-app"]
CMD ["java", "-jar", "helidon-examples-employee-app.jar"]
EXPOSE 8080

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -38,7 +38,7 @@ RUN mvn -f opentracing/pom.xml package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -48,4 +48,4 @@ COPY --from=build /helidon/opentracing/target/libs ./libs
ENV tracing.host="zipkin"
CMD [ "java", "-jar", "helidon-examples-grpc-opentracing.jar" ]
EXPOSE 1408
EXPOSE 1408

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
#
# 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -32,7 +32,7 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -41,4 +41,4 @@ COPY --from=build /helidon/target/libs ./libs
CMD [ "java", "-jar", "helidon-examples-integrations-datasource-hikaricp.jar" ]
EXPOSE 8080
EXPOSE 8080

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -32,7 +32,7 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -41,4 +41,4 @@ COPY --from=build /helidon/target/libs ./libs
CMD [ "java", "-jar", "helidon-examples-integrations-cdi-jedis.jar" ]
EXPOSE 8080
EXPOSE 8080

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -32,7 +32,7 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -49,4 +49,4 @@ CMD [ "sh", "-c", "exec java \
-Doci.objectstorage.region=\"${OCI_OBJECTSTORAGE_REGION}\" \
-jar helidon-examples-integrations-cdi-oci-objectstorage.jar" ]
EXPOSE 8080
EXPOSE 8080

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.6.3-jdk-11 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.6.3-jdk-11 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.6.3-jdk-11 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon

View File

@@ -27,7 +27,7 @@
<properties>
<helidon.version>2.0.0-SNAPSHOT</helidon.version>
<mainClass>io.helidon.examples.quickstart.mp.Main</mainClass>
<mainClass>io.helidon.microprofile.cdi.Main</mainClass>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
@@ -160,6 +160,7 @@
<addClasspath>true</addClasspath>
<classpathPrefix>libs</classpathPrefix>
<mainClass>${mainClass}</mainClass>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>

View File

@@ -1,70 +0,0 @@
/*
* Copyright (c) 2018, 2020 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.helidon.examples.quickstart.mp;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;
import io.helidon.microprofile.server.Server;
/**
* The application main class.
*/
public final class Main {
/**
* Cannot be instantiated.
*/
private Main() {
}
/**
* Application main entry point.
* @param args command line arguments
* @throws IOException if there are problems reading logging properties
*/
public static void main(final String[] args) throws IOException {
// load logging configuration
setupLogging();
// start the server
Server server = startServer();
System.out.println("http://localhost:" + server.port() + "/greet");
}
/**
* Start the server.
* @return the created {@link Server} instance
*/
static Server startServer() {
// Server will automatically pick up configuration from
// microprofile-config.properties
// and Application classes annotated as @ApplicationScoped
return Server.create().start();
}
/**
* Configure logging from logging.properties file.
*/
private static void setupLogging() throws IOException {
try (InputStream is = Main.class.getResourceAsStream("/logging.properties")) {
LogManager.getLogManager().readConfiguration(is);
}
}
}

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,13 +18,13 @@
# For more information see $JAVA_HOME/jre/lib/logging.properties
## Send messages to the console
#handlers=io.helidon.common.HelidonConsoleHandler
handlers=io.helidon.common.HelidonConsoleHandler
#
## HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread
#java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
#
## Global logging level. Can be overridden by specific loggers
#.level=INFO
.level=INFO
#
# Component specific log levels
#io.helidon.webserver.level=INFO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ class MainTest {
@BeforeAll
public static void startTheServer() throws Exception {
server = Main.startServer();
server = Server.create().start();
}
@Test

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.6.3-jdk-11 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon

View File

@@ -163,6 +163,7 @@
<addClasspath>true</addClasspath>
<classpathPrefix>libs</classpathPrefix>
<mainClass>${mainClass}</mainClass>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -32,7 +32,7 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -41,4 +41,4 @@ COPY --from=build /helidon/target/libs ./libs
CMD ["java", "-jar", "helidon-examples-todo-backend.jar"]
EXPOSE 8080
EXPOSE 8080

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -39,7 +39,7 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -33,7 +33,7 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -44,4 +44,4 @@ ENV tracing.host="zipkin"
CMD ["java", "-jar", "helidon-examples-translator-backend.jar"]
EXPOSE 9080
EXPOSE 9080

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -33,7 +33,7 @@ RUN mvn package -Dmaven.test.skip
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -45,4 +45,4 @@ ENV backend.host="helidon-examples-translator-backend"
CMD ["java", "-jar", "helidon-examples-translator-frontend.jar"]
EXPOSE 8080
EXPOSE 8080

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020 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,7 @@
#
# 1st stage, build the app
FROM maven:3.5.4-jdk-9 as build
FROM maven:3.6-jdk-11 as build
WORKDIR /helidon
@@ -33,7 +33,7 @@ RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM openjdk:8-jre-slim
FROM openjdk:11-jre-slim
WORKDIR /helidon
# Copy the binary built in the 1st stage
@@ -44,4 +44,4 @@ ENV tracing.host="zipkin"
CMD ["java", "-jar", "helidon-examples-webserver-opentracing.jar"]
EXPOSE 8080
EXPOSE 8080