annotate docker/Dockerfile.db @ 9716:c3afc0274bba 3.2.x

Improve Docker-based development setup _ Add demo DEMs and WSPLGEN to artifact server _ Do not unpack unused large DEM files into database image _ Improve README
author Tom Gottfried <tom@intevation.de>
date Mon, 22 Mar 2021 17:35:30 +0100
parents 537fe44f2792
children 13e2d38ad314
rev   line source
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 # Docker file for postgresql 9.4 on debain
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 FROM debian:jessie
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 MAINTAINER tom@intevation.de
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5
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 # Use utf-8
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 RUN echo \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 "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
11 debconf-set-selections && \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 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
13 debconf-set-selections
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15 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
16
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 ENV LC_ALL en_US.UTF-8
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18
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 # Install packages
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22 RUN apt-get update && \
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
23 apt-get install -y postgresql-9.4-postgis-2.1 postgis curl
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
24
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
25 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
26 # Use user postgres to run the next commands
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
27 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28 USER postgres
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 RUN /etc/init.d/postgresql start && \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';"
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 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 # Adjust PostgreSQL configuration so that remote connections to the
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 # database are possible.
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 RUN echo "host all all 0.0.0.0/0 md5" >> \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 /etc/postgresql/9.4/main/pg_hba.conf
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
40 ENV PGCONF /etc/postgresql/9.4/main/postgresql.conf
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
41 RUN echo "listen_addresses='*'" >> $PGCONF
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
42
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 # Expose the PostgreSQL port
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
46 EXPOSE 5432
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49 # Create database
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
51 # Don't mind scary messages like
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
52 # 'FATAL: the database system is starting up'.
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
53 # It's because of the -w
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
54 #
9684
537fe44f2792 Add basic Docker setup for development
Tom Gottfried <tom@intevation.de>
parents: 8817
diff changeset
55 ADD ./backend/doc/schema /opt/d4eriver_db
8795
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
56
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
57 # 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
58 WORKDIR /var/lib/postgresql
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
59 ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz
9716
c3afc0274bba Improve Docker-based development setup
Tom Gottfried <tom@intevation.de>
parents: 9684
diff changeset
60 RUN curl -s "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \
c3afc0274bba Improve Docker-based development setup
Tom Gottfried <tom@intevation.de>
parents: 9684
diff changeset
61 tar --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
62
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
63 ENV PGDATA /var/lib/postgresql/9.4/main
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
64 RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wo "--config_file=$PGCONF" && \
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
65 /opt/d4eriver_db/postgresql-setup.sh && \
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
66 psql -f demodaten/d4e_demodata.dump.sql d4e && \
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
67 createuser -S -D -R seddb && \
9684
537fe44f2792 Add basic Docker setup for development
Tom Gottfried <tom@intevation.de>
parents: 8817
diff changeset
68 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
69 createdb seddb && \
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
70 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
71 psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO seddb" seddb && \
8817
8927ec8a3c32 Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents: 8795
diff changeset
72 /usr/lib/postgresql/9.4/bin/pg_ctl stop
8795
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 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 # 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
76 #
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
77 CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
78 "/var/lib/postgresql/9.4/main", "-c", \
13d5b6c67cef Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79 "config_file=/etc/postgresql/9.4/main/postgresql.conf"]

http://dive4elements.wald.intevation.org