Mercurial > dive4elements > river
comparison docker/Dockerfile.db @ 9720:13e2d38ad314 3.2.x
Improve Docker based setup
_ Make CentOS based images more resilient against package installation
problems
_ Upgrade database image to Debian bullseye to avoid OpenSSL bug that
prevented downloading demo data and do some cleanup in passing
_ Add docker-compose file for more automated setup
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 24 Feb 2022 18:49:02 +0100 |
parents | c3afc0274bba |
children | 95496d21b4da |
comparison
equal
deleted
inserted
replaced
9719:f3aa7a12c86a | 9720:13e2d38ad314 |
---|---|
1 # Docker file for postgresql 9.4 on debain | 1 # Docker file for postgresql 9.4 on debain |
2 | 2 |
3 FROM debian:jessie | 3 FROM debian:bullseye |
4 MAINTAINER tom@intevation.de | 4 LABEL maintainer tom.gottfried@intevation.de |
5 | |
6 ENV PG_VERSION 13 | |
5 | 7 |
6 # | 8 # |
7 # Use utf-8 | 9 # Use utf-8 |
8 # | 10 # |
9 RUN echo \ | 11 RUN echo \ |
17 ENV LC_ALL en_US.UTF-8 | 19 ENV LC_ALL en_US.UTF-8 |
18 | 20 |
19 # | 21 # |
20 # Install packages | 22 # Install packages |
21 # | 23 # |
22 RUN apt-get update && \ | 24 RUN apt-get install -y postgresql-$PG_VERSION-postgis-3 curl |
23 apt-get install -y postgresql-9.4-postgis-2.1 postgis curl | 25 RUN apt-get -y clean |
26 | |
27 ENV PGCONF /etc/postgresql/$PG_VERSION/main/postgresql.conf | |
28 ENV PGBIN /usr/lib/postgresql/$PG_VERSION/bin/ | |
29 ENV PGDATA /var/lib/postgresql/$PG_VERSION/main | |
24 | 30 |
25 # | 31 # |
26 # Use user postgres to run the next commands | 32 # Use user postgres to run the next commands |
27 # | 33 # |
28 USER postgres | 34 USER postgres |
29 | 35 |
30 RUN /etc/init.d/postgresql start && \ | |
31 psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';" | |
32 | |
33 # | 36 # |
34 # Adjust PostgreSQL configuration so that remote connections to the | 37 # Adjust PostgreSQL configuration so that remote connections to the |
35 # database are possible. | 38 # database are possible. |
36 # | 39 # |
37 RUN echo "host all all 0.0.0.0/0 md5" >> \ | 40 RUN echo "host all all 0.0.0.0/0 md5" >> \ |
38 /etc/postgresql/9.4/main/pg_hba.conf | 41 /etc/postgresql/$PG_VERSION/main/pg_hba.conf |
39 | 42 |
40 ENV PGCONF /etc/postgresql/9.4/main/postgresql.conf | |
41 RUN echo "listen_addresses='*'" >> $PGCONF | 43 RUN echo "listen_addresses='*'" >> $PGCONF |
42 | 44 |
43 # | 45 # |
44 # Expose the PostgreSQL port | 46 # Expose the PostgreSQL port |
45 # | 47 # |
53 # It's because of the -w | 55 # It's because of the -w |
54 # | 56 # |
55 ADD ./backend/doc/schema /opt/d4eriver_db | 57 ADD ./backend/doc/schema /opt/d4eriver_db |
56 | 58 |
57 # Go to postgres home for write permissions | 59 # Go to postgres home for write permissions |
58 WORKDIR /var/lib/postgresql | |
59 ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz | 60 ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz |
60 RUN curl -s "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \ | 61 RUN curl -sf "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \ |
61 tar --wildcards -xz 'demodaten/*.dump.sql' | 62 tar -C $HOME --wildcards -xz 'demodaten/*.dump.sql' |
62 | 63 |
63 ENV PGDATA /var/lib/postgresql/9.4/main | 64 RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \ |
64 RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wo "--config_file=$PGCONF" && \ | |
65 /opt/d4eriver_db/postgresql-setup.sh && \ | 65 /opt/d4eriver_db/postgresql-setup.sh && \ |
66 psql -f demodaten/d4e_demodata.dump.sql d4e && \ | 66 psql -f ~/demodaten/d4e_demodata.dump.sql d4e && \ |
67 createuser -S -D -R seddb && \ | 67 createuser -S -D -R seddb && \ |
68 psql -c "ALTER USER seddb WITH PASSWORD 'seddb'" && \ | 68 psql -c "ALTER USER seddb WITH PASSWORD 'seddb'" && \ |
69 createdb seddb && \ | 69 createdb seddb && \ |
70 psql -f demodaten/seddb_demodata.dump.sql seddb && \ | 70 psql -f ~/demodaten/seddb_demodata.dump.sql seddb && \ |
71 psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO seddb" seddb && \ | 71 psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO seddb" seddb && \ |
72 /usr/lib/postgresql/9.4/bin/pg_ctl stop | 72 $PGBIN/pg_ctl stop -m smart |
73 | |
74 RUN rm -r ~/demodaten | |
73 | 75 |
74 # | 76 # |
75 # Set the default command to run when starting the container | 77 # Set the default command to run when starting the container |
76 # | 78 # |
77 CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \ | 79 CMD ["/usr/lib/postgresql/13/bin/postgres", "-D", \ |
78 "/var/lib/postgresql/9.4/main", "-c", \ | 80 "/var/lib/postgresql/13/main", "-c", \ |
79 "config_file=/etc/postgresql/9.4/main/postgresql.conf"] | 81 "config_file=/etc/postgresql/13/main/postgresql.conf"] |