diff docker/Dockerfile.gwt-client @ 9795:8d71363cd3bd 3.2.x

Use multi-stage build to speedup build and shrink image
author Tom Gottfried <tom@intevation.de>
date Thu, 02 Nov 2023 14:37:47 +0100
parents df61a569a289
children 13351afee667
line wrap: on
line diff
--- a/docker/Dockerfile.gwt-client	Thu Nov 02 11:20:50 2023 +0100
+++ b/docker/Dockerfile.gwt-client	Thu Nov 02 14:37:47 2023 +0100
@@ -1,18 +1,15 @@
 # Docker file for D4E River GWT client
 
-FROM centos:7
+FROM centos:7 AS base
 MAINTAINER tom@intevation.de
 
 # Necessary to run further yum-installs inside Docker container,
 # if not already part of the base image:
 RUN yum -q -y install yum-plugin-ovl && rpm --rebuilddb
 
+FROM base AS build
 # Install prerequisites
-RUN yum -q -y install maven mercurial tomcat gnu-free-sans-fonts curl
-
-# Prevent Tomcat from logging to files
-# (JRE default is logging to System.err)
-RUN rm /etc/tomcat/logging.properties
+RUN yum -q -y install maven mercurial curl
 
 WORKDIR /opt/d4e
 ENV REPO_URL https://hg.wald.intevation.org/dive4elements/
@@ -45,15 +42,24 @@
         --exclude=OpenLayers-2.11/examples -xf OpenLayers-2.11.tar.gz
 RUN rm OpenLayers-2.11.tar.gz
 
-RUN mvn -q -f river/gwt-client/pom.xml package && \
-    mv river/gwt-client/target/gwt-client-*.war \
-        /usr/share/tomcat/webapps/d4e-river.war
+RUN mvn -q -f river/gwt-client/pom.xml package
+
+FROM base
+RUN yum -q -y install tomcat gnu-free-sans-fonts
+
+# Prevent Tomcat from logging to files
+# (JRE default is logging to System.err)
+RUN rm /etc/tomcat/logging.properties
 
 # Configure tomcat
 RUN sed -i '/Connector port="8080"/a \URIEncoding="UTF-8"' /etc/tomcat/server.xml
 RUN ln -sf /opt/d4e/river/gwt-client/config/context.xml /etc/tomcat
 VOLUME /opt/d4e/river/gwt-client/config
 
+# Deploy
+COPY --from=build /opt/d4e/river/gwt-client/target/gwt-client-*.war \
+        /usr/share/tomcat/webapps/d4e-river.war
+
 USER tomcat
 ADD docker/flys_user_file /usr/share/tomcat/
 

http://dive4elements.wald.intevation.org