Skip to content

Commit

Permalink
Merge pull request #12762 from glefloch/fix/12706
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy authored Oct 20, 2020
2 parents 1134ffd + 6911f69 commit a21f2bc
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the container image run:
#
# {#insert quarkusbuild} mvn package {/}
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.{type} -t quarkus/{project.artifact-id}-{type} .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/{project.artifact-id}-{type}
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/{project.artifact-id}-{type}
#
###
FROM {#insert image /}
{#insert args /}
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates $\{JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/$\{RUN_JAVA_VERSION}/run-java-sh-$\{RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
{#insert copy /}

EXPOSE 8080
USER 1001

ENTRYPOINT [ "/deployments/run-java.sh" ]
Original file line number Diff line number Diff line change
@@ -1,57 +1,16 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the container image run:
#
# mvn package -Dquarkus.package.type=fast-jar
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.fast-jar -t quarkus/{project.artifact-id}-fast-jar .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/{project.artifact-id}-fast-jar
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/{project.artifact-id}-fast-jar
#
###
FROM {dockerfile.fast-jar.from}

{#include Dockerfile-layout type='fast-jar'}
{#quarkusbuild}mvn package -Pquarkus.package.type=fast-jar{/quarkusbuild}
{#image}{dockerfile.fast-jar.from} {/image}
{#args}
ARG JAVA_PACKAGE={dockerfile.fast-jar.java-package}
ARG RUN_JAVA_VERSION={dockerfile.fast-jar.run-java-version}

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'

# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates $\{JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/$\{RUN_JAVA_VERSION}/run-java-sh-$\{RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"

{/args}
{#copy}
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/lib/ /deployments/lib/
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/*.jar /deployments/
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/app/ /deployments/app/
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/quarkus/ /deployments/quarkus/
{/copy}
{/include}

EXPOSE 8080
USER 1001

ENTRYPOINT [ "/deployments/run-java.sh" ]
Original file line number Diff line number Diff line change
@@ -1,54 +1,11 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the container image run:
#
# mvn package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/{project.artifact-id}-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/{project.artifact-id}-jvm
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/{project.artifact-id}-jvm
#
###
FROM {dockerfile.jvm.from}

{#include Dockerfile-layout type='jvm'}
{#image}{dockerfile.jvm.from} {/}
{#args}
ARG JAVA_PACKAGE={dockerfile.jvm.java-package}
ARG RUN_JAVA_VERSION={dockerfile.jvm.run-java-version}

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'

# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates $\{JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/$\{RUN_JAVA_VERSION}/run-java-sh-$\{RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"

{/args}
{#copy}
COPY {buildtool.build-dir}/lib/* /deployments/lib/
COPY {buildtool.build-dir}/*-runner.jar /deployments/app.jar

EXPOSE 8080
USER 1001

ENTRYPOINT [ "/deployments/run-java.sh" ]
{/copy}
{/include}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ COPY --chown=1001:root {buildtool.build-dir}/*-runner /work/application
EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,21 @@ private void checkNoExample(Path projectDir) {

private void checkDockerfiles(Path projectDir) {
assertThat(projectDir.resolve(".dockerignore")).exists();
assertThat(projectDir.resolve("src/main/docker/Dockerfile.jvm")).exists();
assertThat(projectDir.resolve("src/main/docker/Dockerfile.native")).exists();
assertThat(projectDir.resolve("src/main/docker/Dockerfile.fast-jar")).exists();
assertThat(projectDir.resolve("src/main/docker/Dockerfile.jvm")).exists()
.satisfies(checkContains("mvn package"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.jvm"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.fast-jar")).exists()
.satisfies(checkContains("mvn package -Pquarkus.package.type=fast-jar"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.fast-jar"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.native")).exists()
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
}

private void checkConfigProperties(Path projectDir) {
Expand Down

0 comments on commit a21f2bc

Please sign in to comment.