[PATCH] Improve server deployment in Docker container

Wald Commits scm-commit at wald.intevation.org
Fri Jul 15 16:25:45 CEST 2022


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1657895096 -7200
#      Fri Jul 15 16:24:56 2022 +0200
# Branch 3.2.x
# Node ID 1dfcbb09c231cdc8711310de639ea00f7ed13a80
# Parent  7f8110eed9a3d8416f7683717d11c20e90538e87
Improve server deployment in Docker container

_ Compile during build instead of with CMD
_ No longer run service as root user

diff -r 7f8110eed9a3 -r 1dfcbb09c231 docker/Dockerfile.artifacts
--- a/docker/Dockerfile.artifacts	Tue Jul 12 16:34:28 2022 +0200
+++ b/docker/Dockerfile.artifacts	Fri Jul 15 16:24:56 2022 +0200
@@ -18,7 +18,7 @@
     tar -C $DEM_DIR --strip-components=1 --wildcards -xz 'demodaten/dem*.grd'
 
 
-WORKDIR /opt/d4e
+WORKDIR /opt/d4e/src
 ENV REPO_URL https://scm.wald.intevation.org/hg/dive4elements/
 ENV BRANCH 3.2.x
 RUN hg clone -b $BRANCH $REPO_URL/framework
@@ -38,15 +38,18 @@
 RUN curl -s $WSPLGEN_URL | gunzip > bin/wsplgen && chmod +x bin/wsplgen
 
 # Create h2 databases
-RUN ../../framework/artifact-database/bin/createArtifacts.sh && \
-    mv artifactsdb doc/
-RUN ./bin/createDatacage.sh && \
-    mv datacagedb doc/
+RUN ../../framework/artifact-database/bin/createArtifacts.sh
+RUN ./bin/createDatacage.sh
+
+RUN mvn -q package assembly:single
 
 EXPOSE 8181
 
-CMD mvn -Dexec.mainClass=org.dive4elements.artifactdatabase.App \
-        -Dlog4j2.configurationFile="file:///opt/d4e/river/artifacts/doc/conf/log4j2.xml" \
-        -Dartifact.database.dir="/opt/d4e/river/artifacts/doc/conf" \
-        -Dwsplgen.bin.path="/opt/d4e/river/artifacts/bin/wsplgen" \
-        compile exec:java
+WORKDIR /opt/d4e/bin
+RUN useradd d4e
+RUN chown d4e:d4e .
+USER d4e
+
+RUN tar -xf ../src/river/artifacts/target/river-artifacts-1.0-SNAPSHOT-bin.tar
+
+CMD bin/run.sh


More information about the Dive4Elements-commits mailing list