changeset 9734:95496d21b4da 3.2.x

Add MapServer to Docker setup
author Tom Gottfried <tom@intevation.de>
date Fri, 22 Jul 2022 17:56:11 +0200
parents 93b9034613bc
children fff6c15cdcb1
files docker/Dockerfile.db docker/Dockerfile.mapserv docker/README docker/docker-compose.yml docker/httpd-mapserver.conf docker/ol7-temp.repo docker/river-wms docker/user-wms
diffstat 8 files changed, 99 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/docker/Dockerfile.db	Fri Jul 22 13:07:07 2022 +0200
+++ b/docker/Dockerfile.db	Fri Jul 22 17:56:11 2022 +0200
@@ -1,5 +1,4 @@
-# Docker file for postgresql 9.4 on debain
-
+# Dockerfile providing a PostgreSQL database with example data for D4E River
 FROM debian:bullseye
 LABEL maintainer tom.gottfried@intevation.de
 
@@ -61,9 +60,12 @@
 RUN curl -sf "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \
     tar -C $HOME --wildcards -xz 'demodaten/*.dump.sql'
 
+# Initialize database
+# Note that PostGIS legacy.sql is needed to support the outdated MapServer 6
 RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \
     /opt/d4eriver_db/postgresql-setup.sh && \
     psql -f ~/demodaten/d4e_demodata.dump.sql d4e && \
+    psql -d d4e -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-3.1/legacy.sql && \
     createuser -S -D -R seddb && \
     psql -c "ALTER USER seddb WITH PASSWORD 'seddb'" && \
     createdb seddb && \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/Dockerfile.mapserv	Fri Jul 22 17:56:11 2022 +0200
@@ -0,0 +1,52 @@
+# Docker file for D4E River MapServer
+# with support for PostgreSQL and Oracle databases
+
+FROM centos:7
+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
+
+# Install prerequisites
+RUN yum -q -y install curl ca-certificates epel-release \
+        gnu-free-sans-fonts httpd
+RUN yum -q -y install gcc-c++ postgresql-devel gd-devel giflib-devel proj-devel \
+        proj-epsg prelink make
+
+# Install Oracle client
+RUN curl -s https://yum.oracle.com/RPM-GPG-KEY-oracle-ol7 \
+        -o /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
+ADD ol7-temp.repo /etc/yum.repos.d/
+RUN yum -q -y install oraclelinux-release-el7
+RUN mv /etc/yum.repos.d/ol7-temp.repo /etc/yum.repos.d/ol7-temp.repo.disabled
+RUN yum -q -y install oracle-release-el7
+RUN yum -q -y install oracle-instantclient19.9-basic \
+        oracle-instantclient19.9-devel
+RUN yum-config-manager --disable oracle*,ol7*
+
+# Install MapServer
+WORKDIR /opt/mapserver
+RUN curl -s https://download.osgeo.org/mapserver/mapserver-6.0.6.tar.gz | tar xz
+WORKDIR mapserver-6.0.6
+RUN sed -i "s@oracle/10\*/client@oracle/19.9/client64@g" configure
+RUN ./configure -q --with-proj --with-postgis --with-oraclespatial=/usr \
+        CFLAGS=-w CXXFLAGS=-w
+RUN make -s
+WORKDIR /opt/mapserver
+RUN ln -s mapserver-6.0.6/mapserv
+
+# Volume to share mapfiles with artifact server.
+# Has to be the same path as in artifact server container because mapfiles
+# contain absolute paths.
+VOLUME /opt/d4e/bin
+
+# CGI scripts
+ADD river-wms /var/www/cgi-bin/
+ADD user-wms /var/www/cgi-bin/
+
+# httpd config
+ADD httpd-mapserver.conf /etc/httpd/conf.d/
+
+EXPOSE 80
+CMD ["/usr/sbin/httpd", "-DFOREGROUND"]
--- a/docker/README	Fri Jul 22 13:07:07 2022 +0200
+++ b/docker/README	Fri Jul 22 17:56:11 2022 +0200
@@ -4,6 +4,8 @@
 _ 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
+_ Change 'localhost' to the hostname of your docker host in
+  artifacts/doc/conf/floodmap.xml and artifacts/doc/conf/rivermap.xml
 
 
 Build and run:
--- a/docker/docker-compose.yml	Fri Jul 22 13:07:07 2022 +0200
+++ b/docker/docker-compose.yml	Fri Jul 22 17:56:11 2022 +0200
@@ -18,6 +18,24 @@
       - d4e_river
     depends_on:
       - db
+    volumes:
+      - ../artifacts/doc/conf:/opt/d4e/bin/conf
+      - mapfiles:/opt/d4e/bin
+  mapserv:
+    container_name: "d4eriver-mapserv"
+    build:
+      context: ./
+      dockerfile: ./Dockerfile.mapserv
+    image: "d4e/river_mapserv"
+    networks:
+      - d4e_river
+    depends_on:
+      - db
+      - server
+    volumes:
+      - mapfiles:/opt/d4e/bin
+    ports:
+      - 8081:80
   client:
     container_name: "d4eriver-client"
     build:
@@ -28,6 +46,7 @@
       - d4e_river
     depends_on:
       - server
+      - mapserv
     volumes:
       - ../:/opt/d4e/river
     ports:
@@ -35,3 +54,5 @@
 networks:
   d4e_river:
     name: d4e_river
+volumes:
+  mapfiles:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/httpd-mapserver.conf	Fri Jul 22 17:56:11 2022 +0200
@@ -0,0 +1,4 @@
+<VirtualHost *:80>
+	ErrorLog /dev/stderr
+	CustomLog /dev/stdout combined
+</VirtualHost>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/ol7-temp.repo	Fri Jul 22 17:56:11 2022 +0200
@@ -0,0 +1,6 @@
+[ol7_latest]
+name=Oracle Linux 7 Latest (x86_64)
+baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
+gpgcheck=1
+enabled=1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/river-wms	Fri Jul 22 17:56:11 2022 +0200
@@ -0,0 +1,5 @@
+#!/bin/sh
+export LC_ALL="de_DE.UTF-8"
+export NLS_LANG=".AL32UTF8"
+export MS_MAPFILE=/opt/d4e/bin/rivers.map
+/opt/mapserver/mapserv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/user-wms	Fri Jul 22 17:56:11 2022 +0200
@@ -0,0 +1,5 @@
+#!/bin/sh
+export LC_ALL="de_DE.UTF-8"
+export NLS_LANG=".AL32UTF8"
+export MS_MAPFILE=/opt/d4e/bin/flys.map
+/opt/mapserver/mapserv

http://dive4elements.wald.intevation.org