changeset 9684:537fe44f2792 3.2.x

Add basic Docker setup for development
author Tom Gottfried <tom@intevation.de>
date Thu, 30 Jul 2020 19:00:44 +0200
parents 8e5a8430b89c
children 2dad42df79a8
files .dockerignore backend/doc/schema/Dockerfile docker/Dockerfile.artifacts docker/Dockerfile.db docker/Dockerfile.gwt-client docker/README docker/flys_user_file
diffstat 7 files changed, 185 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.dockerignore	Thu Jul 30 19:00:44 2020 +0200
@@ -0,0 +1,5 @@
+*/target
+*.h2.db
+*.lock.db
+*.trace.db
+*.map
--- a/backend/doc/schema/Dockerfile	Thu Jun 04 20:16:37 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-# Docker file for postgresql 9.4 on debain
-#
-# build with e.g. `docker build --force-rm=true -t d4e/river_db .',
-# then run with e.g.
-# `docker run --name d4eriver_db -dp 2345:5432 d4e/river_db:latest'
-#
-
-FROM debian:jessie
-MAINTAINER tom@intevation.de
-
-#
-# Use utf-8
-#
-RUN echo \
-    "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \
-    debconf-set-selections && \
-    echo "locales locales/default_environment_locale select en_US.UTF-8" | \
-    debconf-set-selections
-
-RUN apt-get update -y && apt-get install -y locales
-
-ENV LC_ALL en_US.UTF-8
-
-#
-# Install packages
-#
-RUN apt-get update && \
-    apt-get install -y postgresql-9.4-postgis-2.1 postgis curl
-
-#
-# Use user postgres to run the next commands
-#
-USER postgres
-
-RUN /etc/init.d/postgresql start && \
-    psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';"
-
-#
-# Adjust PostgreSQL configuration so that remote connections to the
-# database are possible.
-#
-RUN echo "host all  all    0.0.0.0/0  md5" >> \
-    /etc/postgresql/9.4/main/pg_hba.conf
-
-ENV PGCONF /etc/postgresql/9.4/main/postgresql.conf
-RUN echo "listen_addresses='*'" >> $PGCONF
-
-#
-# Expose the PostgreSQL port
-#
-EXPOSE 5432
-
-#
-# Create database
-#
-# Don't mind scary messages like
-# 'FATAL: the database system is starting up'.
-# It's because of the -w
-#
-ADD . /opt/d4eriver_db
-
-# Go to postgres home for write permissions
-WORKDIR /var/lib/postgresql
-ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz
-RUN curl -k "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \
-    tar xz
-
-ENV PGDATA /var/lib/postgresql/9.4/main
-RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wo "--config_file=$PGCONF" && \
-    /opt/d4eriver_db/postgresql-setup.sh && \
-    psql -f demodaten/d4e_demodata.dump.sql d4e && \
-    createuser -S -D -R seddb && \
-    createdb seddb && \
-    psql -f demodaten/seddb_demodata.dump.sql seddb && \
-    /usr/lib/postgresql/9.4/bin/pg_ctl stop
-
-#
-# Set the default command to run when starting the container
-#
-CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \
-     "/var/lib/postgresql/9.4/main", "-c", \
-     "config_file=/etc/postgresql/9.4/main/postgresql.conf"]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/Dockerfile.artifacts	Thu Jul 30 19:00:44 2020 +0200
@@ -0,0 +1,32 @@
+# Docker file for D4E River artifact server
+
+FROM centos:7
+MAINTAINER tom@intevation.de
+
+# Install prerequisites
+RUN yum -y install maven mercurial
+
+WORKDIR /opt/d4e
+ENV REPO_URL https://scm.wald.intevation.org/hg/dive4elements/
+ENV BRANCH 3.2.x
+RUN hg clone -b $BRANCH $REPO_URL/framework
+RUN hg clone -b $BRANCH $REPO_URL/http-client
+
+RUN mvn -q -f framework/pom.xml install
+RUN mvn -q -f http-client/pom.xml install
+
+ADD . river
+
+RUN mvn -q -f river/backend/pom.xml install
+
+WORKDIR river/artifacts
+RUN ../../framework/artifact-database/bin/createArtifacts.sh && \
+    mv artifactsdb doc/
+RUN ./bin/createDatacage.sh && \
+    mv datacagedb doc/
+
+EXPOSE 8181
+
+CMD mvn -Dexec.mainClass=org.dive4elements.artifactdatabase.App \
+        -Dartifact.database.dir="/opt/d4e/river/artifacts/doc/conf" \
+        compile exec:java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/Dockerfile.db	Thu Jul 30 19:00:44 2020 +0200
@@ -0,0 +1,79 @@
+# Docker file for postgresql 9.4 on debain
+
+FROM debian:jessie
+MAINTAINER tom@intevation.de
+
+#
+# Use utf-8
+#
+RUN echo \
+    "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \
+    debconf-set-selections && \
+    echo "locales locales/default_environment_locale select en_US.UTF-8" | \
+    debconf-set-selections
+
+RUN apt-get update -y && apt-get install -y locales
+
+ENV LC_ALL en_US.UTF-8
+
+#
+# Install packages
+#
+RUN apt-get update && \
+    apt-get install -y postgresql-9.4-postgis-2.1 postgis curl
+
+#
+# Use user postgres to run the next commands
+#
+USER postgres
+
+RUN /etc/init.d/postgresql start && \
+    psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';"
+
+#
+# Adjust PostgreSQL configuration so that remote connections to the
+# database are possible.
+#
+RUN echo "host all  all    0.0.0.0/0  md5" >> \
+    /etc/postgresql/9.4/main/pg_hba.conf
+
+ENV PGCONF /etc/postgresql/9.4/main/postgresql.conf
+RUN echo "listen_addresses='*'" >> $PGCONF
+
+#
+# Expose the PostgreSQL port
+#
+EXPOSE 5432
+
+#
+# Create database
+#
+# Don't mind scary messages like
+# 'FATAL: the database system is starting up'.
+# It's because of the -w
+#
+ADD ./backend/doc/schema /opt/d4eriver_db
+
+# Go to postgres home for write permissions
+WORKDIR /var/lib/postgresql
+ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz
+RUN curl -k "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \
+    tar xz
+
+ENV PGDATA /var/lib/postgresql/9.4/main
+RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wo "--config_file=$PGCONF" && \
+    /opt/d4eriver_db/postgresql-setup.sh && \
+    psql -f demodaten/d4e_demodata.dump.sql d4e && \
+    createuser -S -D -R seddb && \
+    psql -c "ALTER USER seddb WITH PASSWORD 'seddb'" && \
+    createdb seddb && \
+    psql -f demodaten/seddb_demodata.dump.sql seddb && \
+    psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO seddb" seddb && \
+    /usr/lib/postgresql/9.4/bin/pg_ctl stop
+
+#
+# Set the default command to run when starting the container
+#
+CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \
+     "/var/lib/postgresql/9.4/main", "-c", \
+     "config_file=/etc/postgresql/9.4/main/postgresql.conf"]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/Dockerfile.gwt-client	Thu Jul 30 19:00:44 2020 +0200
@@ -0,0 +1,34 @@
+# Docker file for D4E River GWT client
+
+FROM centos:7
+MAINTAINER tom@intevation.de
+
+# Install prerequisites
+RUN yum -y install maven mercurial tomcat
+
+WORKDIR /opt/d4e
+ENV REPO_URL https://scm.wald.intevation.org/hg/dive4elements/
+ENV BRANCH 3.2.x
+RUN hg clone -b $BRANCH $REPO_URL/framework
+RUN hg clone -b $BRANCH $REPO_URL/http-client
+
+RUN mvn -q -f framework/pom.xml install
+RUN mvn -q -f http-client/pom.xml install
+
+# Use latest patch release and fake version=4.1-p20141119 to work around
+# the actual version (which is known to work properly)
+# is not publicly available
+RUN curl -O https://www.smartclient.com/builds/SmartGWT/4.1p/LGPL/latest/smartgwt.jar
+
+ADD . river
+
+RUN mvn -q install:install-file -Dfile=smartgwt.jar -Dversion=4.1-p20141119 \
+    -DartifactId=smartgwt-lgpl -DgroupId=com.isomorphic.smartgwt.lgpl \
+    -Dpackaging=jar
+RUN mvn -q -f river/gwt-client/pom.xml package && \
+    mv river/gwt-client/target/gwt-client-*.war /usr/share/tomcat/webapps
+
+ADD docker/flys_user_file /root/
+
+EXPOSE 8080
+CMD ["/usr/libexec/tomcat/server", "start"]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/README	Thu Jul 30 19:00:44 2020 +0200
@@ -0,0 +1,33 @@
+Configure:
+_ Change 'localhost' to 'd4eriver-db' in artifacts/doc/conf/backend-db.xml
+  and artifacts/doc/conf/seddb-db.xml
+_ Change 'localhost' to '0.0.0.0' in artifacts/doc/conf/rest-server.xml
+_ Change 'localhost' to 'd4eriver-artifacts' in the server-url parameter in
+  gwt-client/src/main/webapp/WEB-INF/web.xml
+
+
+Build:
+
+$ docker build -f docker/Dockerfile.db -t d4e/river_db .
+$ docker build -f docker/Dockerfile.artifacts -t d4e/river_artifacts .
+$ docker build -f docker/Dockerfile.gwt-client -t d4e/river_client .
+
+
+Run:
+
+$ docker network create d4e_river
+$ docker run --name d4eriver-db  --network d4e_river \
+    -dp 2345:5432 d4e/river_db:latest
+$ docker run --name d4eriver-artifacts --network d4e_river \
+    -dp 8181:8181 d4e/river_artifacts
+$ docker run --name d4eriver-client --network d4e_river \
+    -v $PWD:/opt/d4e/river -dp 8080:8080 d4e/river_client
+
+
+TODO:
+_ Avoid having to change configuration manually
+_ Allow running artifact server with `-v $PWD:/opt/d4e/river'
+  (currently this leads to missing h2 databases)
+_ Let all components log to stdout to enable useful usage of `docker logs'
+_ Something better than setting framework and http-client to a branch
+  explicitly in the Dockerfiles
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/flys_user_file	Thu Jul 30 19:00:44 2020 +0200
@@ -0,0 +1,2 @@
+d4e_demo demo d4e_demo_all
+d4e_demo_extern demo d4e_demo_extern

http://dive4elements.wald.intevation.org