annotate docker/Dockerfile.db @ 9755:0834c2591e14 3.2.x

Route MapServer through wiki container This reduces the need for local configuration changes to get a working Docker-based setup.
author Tom Gottfried <tom@intevation.de>
date Wed, 12 Oct 2022 12:53:36 +0200
parents 0c4736d5dd4a
children f98e5c7775d2
rev   line source
9734
95496d21b4da Add MapServer to Docker setup
Tom Gottfried <tom@intevation.de>
parents: 9720
diff changeset
1 # Dockerfile providing a PostgreSQL database with example data for D4E River
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
2 FROM debian:bullseye
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
3 LABEL maintainer tom.gottfried@intevation.de
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
4
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
5 ENV PG_VERSION 13
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 # Use utf-8
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 RUN echo \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11 "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 debconf-set-selections && \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
13 echo "locales locales/default_environment_locale select en_US.UTF-8" | \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14 debconf-set-selections
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16 RUN apt-get update -y && apt-get install -y locales
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18 ENV LC_ALL en_US.UTF-8
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 # Install packages
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22 #
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
23 RUN apt-get install -y postgresql-$PG_VERSION-postgis-3 curl
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
24 RUN apt-get -y clean
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
25
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
26 ENV PGCONF /etc/postgresql/$PG_VERSION/main/postgresql.conf
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
27 ENV PGBIN /usr/lib/postgresql/$PG_VERSION/bin/
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
28 ENV PGDATA /var/lib/postgresql/$PG_VERSION/main
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 # Use user postgres to run the next commands
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
33 USER postgres
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 # Adjust PostgreSQL configuration so that remote connections to the
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 # database are possible.
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39 RUN echo "host all all 0.0.0.0/0 md5" >> \
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
40 /etc/postgresql/$PG_VERSION/main/pg_hba.conf
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
41
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
42 RUN echo "listen_addresses='*'" >> $PGCONF
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
43
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
44 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45 # Create database
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
46 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47 # Don't mind scary messages like
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 # 'FATAL: the database system is starting up'.
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49 # It's because of the -w
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 #
9684
537fe44f2792 Add basic Docker setup for development
Tom Gottfried <tom@intevation.de>
parents: 8817
diff changeset
51 ADD ./backend/doc/schema /opt/d4eriver_db
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
52
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
53 # Go to postgres home for write permissions
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
54 ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
55 RUN curl -sf "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
56 tar -C $HOME --wildcards -xz 'demodaten/*.dump.sql'
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
57
9734
95496d21b4da Add MapServer to Docker setup
Tom Gottfried <tom@intevation.de>
parents: 9720
diff changeset
58 # Initialize database
95496d21b4da Add MapServer to Docker setup
Tom Gottfried <tom@intevation.de>
parents: 9720
diff changeset
59 # Note that PostGIS legacy.sql is needed to support the outdated MapServer 6
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
60 RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
61 /opt/d4eriver_db/postgresql-setup.sh && \
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
62 psql -f ~/demodaten/d4e_demodata.dump.sql d4e && \
9734
95496d21b4da Add MapServer to Docker setup
Tom Gottfried <tom@intevation.de>
parents: 9720
diff changeset
63 psql -d d4e -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-3.1/legacy.sql && \
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
64 createuser -S -D -R seddb && \
9684
537fe44f2792 Add basic Docker setup for development
Tom Gottfried <tom@intevation.de>
parents: 8817
diff changeset
65 psql -c "ALTER USER seddb WITH PASSWORD 'seddb'" && \
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
66 createdb seddb && \
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
67 psql -f ~/demodaten/seddb_demodata.dump.sql seddb && \
9684
537fe44f2792 Add basic Docker setup for development
Tom Gottfried <tom@intevation.de>
parents: 8817
diff changeset
68 psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO seddb" seddb && \
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
69 $PGBIN/pg_ctl stop -m smart
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
70
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
71 RUN rm -r ~/demodaten
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
72
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
73 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
74 # Set the default command to run when starting the container
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 #
9720
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
76 CMD ["/usr/lib/postgresql/13/bin/postgres", "-D", \
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
77 "/var/lib/postgresql/13/main", "-c", \
13e2d38ad314 Improve Docker based setup
Tom Gottfried <tom@intevation.de>
parents: 9716
diff changeset
78 "config_file=/etc/postgresql/13/main/postgresql.conf"]

http://dive4elements.wald.intevation.org