Skip to content

Commit

Permalink
build: improved java 11 dockefile by building from tomcat image
Browse files Browse the repository at this point in the history
  • Loading branch information
MLenterman committed Aug 30, 2023
1 parent 8cf6ca1 commit 6016c5a
Showing 1 changed file with 39 additions and 14 deletions.
53 changes: 39 additions & 14 deletions Dockerfile.java11
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
FROM docker.io/wearefrank/frank-framework:7.9-20230810.190012
FROM tomcat:8-jre11-temurin-jammy AS base

ARG GID=1000
ARG UID=1000

# Secure files (CIS-DI-0008)
RUN chmod -R 751 /usr/bin /usr/sbin

# Create folder and user, and set file permissions
RUN set -eux && \
# Create default directory for configurations, properties and credential filesystem
mkdir -p /opt/frank/secrets && \
# Create tomcat user for stepping down from root
groupadd -g ${GID} tomcat && \
useradd -u ${UID} -g tomcat -s /usr/sbin/nologin -l tomcat && \
# Change permissions and ownership of files
chown -hR tomcat:tomcat ${CATALINA_HOME} && \
chown -hR tomcat:tomcat /opt/frank

# All previous actions are performed as root. Run following instructions and start container as tomcat.
USER tomcat

# Copy environment configuration
COPY --from=docker.io/wearefrank/frank-framework:7.9-20230810.190012 --chown=tomcat /usr/local/tomcat/conf/catalina.properties /usr/local/tomcat/conf/catalina.properties
COPY --from=docker.io/wearefrank/frank-framework:7.9-20230810.190012 --chown=tomcat /usr/local/tomcat/lib/ /usr/local/tomcat/lib/
COPY --from=docker.io/wearefrank/frank-framework:7.9-20230810.190012 --chown=tomcat /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT

# TempFix TODO: Move this to the credentialprovider.properties
ENV credentialFactory.class=nl.nn.credentialprovider.PropertyFileCredentialFactory
Expand All @@ -17,22 +42,22 @@ COPY --chown=tomcat src/main/configurations/ /opt/frank/configurations/
COPY --chown=tomcat src/main/resources/ /opt/frank/resources/
COPY --chown=tomcat src/test/testtool/ /opt/frank/testtool/

USER root
RUN wget -P /tmp/java11/ https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.20%2B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.20_8.tar.gz \
&& tar -zxvf /tmp/java11/OpenJDK11U-jdk_x64_linux_hotspot_11.0.20_8.tar.gz -C /opt/java/ \
&& rm -rf /tmp/java11/
ENV JAVA_HOME=/opt/java/jdk-11.0.20+8
ENV PATH=$JAVA_HOME/bin:$PATH
ENV JAVA_VERSION=11.0.20+8
USER tomcat
# Compile custom class
FROM eclipse-temurin:8-jdk-jammy AS build

COPY --from=base /usr/local/tomcat/lib/ /usr/local/tomcat/lib/
COPY --from=base /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT

# Compile custom class, this should be changed to a buildstep in the future
COPY --chown=tomcat src/main/java /tmp/java
RUN javac \
COPY src/main/java /tmp/java
RUN mkdir /tmp/classes \
&& javac \
/tmp/java/nl/nn/adapterframework/parameters/Parameter.java \
-classpath "/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/*:/usr/local/tomcat/lib/*" \
-verbose -d /usr/local/tomcat/webapps/ROOT/WEB-INF/classes \
&& rm -rf /tmp/java
-verbose -d /tmp/classes

FROM base AS final

COPY --from=build --chown=tomcat /tmp/classes/ /usr/local/tomcat/webapps/ROOT/WEB-INF/classes

HEALTHCHECK --interval=15s --timeout=5s --start-period=30s --retries=60 \
CMD curl --fail --silent http://localhost:8080/iaf/api/server/health || (curl --silent http://localhost:8080/iaf/api/server/health && exit 1)

0 comments on commit 6016c5a

Please sign in to comment.