Skip to content

Commit

Permalink
Update Dockerfile to use fabric8/java-centos-openjdk8-jre image (#151)
Browse files Browse the repository at this point in the history
When running REMReM Generate in a Docker container there's little point
in using a Tomcat image (tomcat:8.0-jre8) and running the war file as
the sole application in its Tomcat instance. There are also a few
concrete problems in such a setup:

    - Because the process inside the container with pid 1 won't respond
      to SIGTERM signals, container shutdowns will (by default) take
      ten seconds and the processes will be stopped with SIGKILL,
      leaving no opportunity to clean anything up.
    - Tomcat and the application each have their own logging
      configurations, so introducing a common log format or rotation
      means extra work.

By switching to fabric8/java-centos-openjdk8-jre we run the war file as
a standalone application with the Tomcat that's built into Spring Boot.

This commit introduces a backwards incompatible change, namely that
the directory where the application looks for application.properties
changes.

While updating the Docker documentation we also drop references to the
--expose flag since it's superfluous given the "EXPOSE 8080" instruction
in the dockerfile.
  • Loading branch information
magnusbaeck authored and SantoshNC68 committed Nov 26, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 1cf7171 commit 9b4e9a3
Showing 2 changed files with 23 additions and 12 deletions.
18 changes: 12 additions & 6 deletions service/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM tomcat:8.0-jre8
FROM fabric8/java-centos-openjdk8-jre:1.6.4
MAINTAINER Eiffel-Community
EXPOSE 8080
ARG URL
RUN echo Building RemRem-Generate image based on artifact url: ${URL}
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
ADD ${URL} /usr/local/tomcat/webapps/ROOT.war

EXPOSE 8080
CMD ["catalina.sh", "run"]
# Explicitly select the file to pass to "java -jar" so that additional
# jar dependencies can be added to ${JAVA_APP_DIR} without creating
# ambiguity.
ENV JAVA_APP_JAR ${JAVA_APP_DIR}/generate.war

# Disable Jolokia and jmx_exporter.
ENV AB_OFF true

RUN echo Building RemRem-Generate image based on artifact url: ${URL}
ADD --chown=jboss ${URL} ${JAVA_APP_JAR}
17 changes: 11 additions & 6 deletions wiki/markdown/docker.md
Original file line number Diff line number Diff line change
@@ -64,20 +64,25 @@ It is possible to set all Spring available properties via docker envrionment "-e
## Docker flags


<B>"--expose 8080"</B> - this Docker flag tells that containers internal port shall be exposed to outside of the Docker Host. This flag do not set which port that should be allocated outside Docker Host on the actual server/machine.


<B>"-p 8081:8080"</B> - this Docker flag is mapping the containers external port 8081 to the internal exposed port 8080. Port 8081 will be allocated outside Docker host and user will be able to access the containers service via port 8081.


When RemRem-Generate container is running on your local Docker host, RemRem-Generate should be reachable with address "localhost:8081/\<Rest End-Point\>" or "\<docker host ip\>:8081/\<Rest End-Point\>"


Another option to configure RemRem-Generate is to provide the application properties file into the container, which can be made in two ways:
1. Put application.properties file in Tomcat Catalina config folder in container and run RemRem-Generate:
1. Put application.properties file in the container's /deployments folder and run RemRem-Generate:

`docker run -p 8081:8080 --expose 8080 --volume /path/to/application.properties:/usr/local/tomcat/config/application.properties remrem-generate`
`docker run -p 8081:8080 --volume /path/to/application.properties:/deployments/application.properties remrem-generate`

2. Put application.properties file in a different folder in container and tell RemRem-Generate where the application.properties is located in the container:

`docker run -p 8081:8080 --expose 8080 --volume /path/to/application.properties:/tmp/application.properties -e spring.config.location=/tmp/application.properties remrem-generate`
`docker run -p 8081:8080 --volume /path/to/application.properties:/tmp/application.properties -e spring.config.location=/tmp/application.properties remrem-generate`

If you need to pass additional flags to the JVM (like setting a custom
heap size) you can include those flags in the JAVA_OPTIONS environment
variable. See the documentation of the
[fabric8/java-centos-openjdk8-jre][docker-image-docs] Docker image for
full details.

[docker-image-docs]: https://hub.docker.com/r/fabric8/java-centos-openjdk8-jre

0 comments on commit 9b4e9a3

Please sign in to comment.