Skip to content

Commit

Permalink
Fix DockerFiles and documentation
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <[email protected]>
  • Loading branch information
tvallin committed Nov 9, 2023
1 parent 50dec45 commit 3ed9e24
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 63 deletions.
6 changes: 3 additions & 3 deletions archetypes/helidon/src/main/archetype/common/docker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
</includes>
</templates>
<model>
<list key="poms">
<value>pom.xml</value>
<list key="poms" if="!${multi-module}">
<value>ADD pom.xml .</value>
</list>
<list key="src-dirs" if="!${multi-module}">
<value>src</value>
<value>ADD src src</value>
</list>
<list key="native-sections" if="${docker.native-image}">
<value file="files/README.native.md"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,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

WORKDIR /usr/share

# Install maven
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ WORKDIR /helidon
# Incremental docker builds will always resume after that, unless you update
# the pom
{{#poms}}
ADD {{.}} {{.}}
{{.}}
{{/poms}}
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip {{#docker-phase1-options}}{{.}}{{^last}} {{/last}}{{/docker-phase1-options}}

# Do the Maven build!
# Incremental docker builds will resume here when you change sources
{{#src-dirs}}
ADD {{.}} {{.}}
{{.}}
{{/src-dirs}}
RUN mvn package -DskipTests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<artifactId>{{artifactId}}</artifactId>
<version>{{project-version}}</version>

<properties>
{{#mainClass}}
<properties>
<mainClass>{{mainClass}}</mainClass>
{{/mainClass}}
</properties>
{{/mainClass}}

<dependencies>
{{#dependencies}}
Expand Down
11 changes: 6 additions & 5 deletions archetypes/helidon/src/main/archetype/mp/oci/oci-mp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,14 @@ Mount this volume as part of your application containers specification
]]></value>
</list>
<list key="poms">
<value>client/pom.xml</value>
<value>server/pom.xml</value>
<value>ADD pom.xml pom.xml</value>
<value>ADD client/pom.xml client/pom.xml</value>
<value>ADD server/pom.xml server/pom.xml</value>
</list>
<list key="src-dirs">
<value>client/src</value>
<value>server/src</value>
<value>spec/api.yaml</value>
<value>ADD client/src client/src</value>
<value>ADD server/src server/src</value>
<value>ADD spec/api.yaml spec/api.yaml</value>
</list>
</model>
</output>
Expand Down
23 changes: 16 additions & 7 deletions docs/mp/guides/mp-tutorial.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand All @@ -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
----
Expand All @@ -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:
Expand Down
15 changes: 12 additions & 3 deletions examples/employee-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand All @@ -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
Expand Down
15 changes: 12 additions & 3 deletions examples/integrations/cdi/datasource-hikaricp/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand All @@ -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
Expand Down
15 changes: 12 additions & 3 deletions examples/quickstarts/helidon-quickstart-mp/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand All @@ -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
Expand Down
13 changes: 11 additions & 2 deletions examples/quickstarts/helidon-quickstart-mp/Dockerfile.jlink
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand All @@ -35,6 +44,6 @@ RUN echo "done!"

FROM debian:stretch-slim
WORKDIR /helidon
COPY --from=build /helidon/target/helidon-quickstart-mp-jri ./
COPY --from=build /helidon/target/helidon-standalone-quickstart-mp-jri ./
ENTRYPOINT ["/bin/bash", "/helidon/bin/start"]
EXPOSE 8080
12 changes: 6 additions & 6 deletions examples/quickstarts/helidon-standalone-quickstart-mp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ Start the application:
Build the "native" Docker Image

```
docker build -t helidon-quickstart-mp-native -f Dockerfile.native .
docker build -t helidon-standalone-quickstart-mp-native -f Dockerfile.native .
```

Start the application:

```
docker run --rm -p 8080:8080 helidon-quickstart-mp-native:latest
docker run --rm -p 8080:8080 helidon-standalone-quickstart-mp-native:latest
```

## Build a Java Runtime Image using jlink
Expand Down Expand Up @@ -141,25 +141,25 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug
Start the application:

```
./target/helidon-quickstart-se-jri/bin/start
./target/helidon-standalone-quickstart-mp-jri/bin/start
```

### Multi-stage Docker build

Build the JRI as a Docker Image

```
docker build -t helidon-quickstart-mp-jri -f Dockerfile.jlink .
docker build -t helidon-standalone-quickstart-mp-jri -f Dockerfile.jlink .
```

Start the application:

```
docker run --rm -p 8080:8080 helidon-quickstart-mp-jri:latest
docker run --rm -p 8080:8080 helidon-standalone-quickstart-mp-jri:latest
```

See the start script help:

```
docker run --rm helidon-quickstart-mp-jri:latest --help
docker run --rm helidon-standalone-quickstart-mp-jri:latest --help
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 3ed9e24

Please sign in to comment.