Mercurial > dive4elements > river
annotate backend/doc/schema/Dockerfile @ 8997:d5802f22e4f5
Work on uinfo
author | gernotbelger |
---|---|
date | Thu, 12 Apr 2018 19:14:19 +0200 |
parents | 8927ec8a3c32 |
children |
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 # build with e.g. `docker build --force-rm=true -t d4e/river_db .', |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 # then run with e.g. |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
5 # `docker run --name d4eriver_db -dp 2345:5432 d4e/river_db:latest' |
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 FROM debian:jessie |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
9 MAINTAINER tom@intevation.de |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 # Use utf-8 |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
14 RUN echo \ |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
15 "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
|
16 debconf-set-selections && \ |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
17 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
|
18 debconf-set-selections |
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 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
|
21 |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
22 ENV LC_ALL en_US.UTF-8 |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
23 |
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 # Install packages |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
26 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
27 RUN apt-get update && \ |
8817
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
28 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
|
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 RUN /etc/init.d/postgresql start && \ |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
36 psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';" |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
37 |
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 # Adjust PostgreSQL configuration so that remote connections to the |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
40 # database are possible. |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
41 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
42 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
|
43 /etc/postgresql/9.4/main/pg_hba.conf |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
44 |
8817
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
45 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
|
46 RUN echo "listen_addresses='*'" >> $PGCONF |
8795
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 # Expose the PostgreSQL port |
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 EXPOSE 5432 |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
52 |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
53 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
54 # Create database |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
55 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
56 # Don't mind scary messages like |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
57 # 'FATAL: the database system is starting up'. |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
58 # It's because of the -w |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
59 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
60 ADD . /opt/d4eriver_db |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
61 |
8817
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
62 # 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
|
63 WORKDIR /var/lib/postgresql |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
64 ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
65 RUN curl -k "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \ |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
66 tar xz |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
67 |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
68 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
|
69 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
|
70 /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
|
71 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
|
72 createuser -S -D -R seddb && \ |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
73 createdb seddb && \ |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
74 psql -f demodaten/seddb_demodata.dump.sql seddb && \ |
8927ec8a3c32
Add demodata and fix server startup in DB Dockerfile.
Tom Gottfried <tom@intevation.de>
parents:
8795
diff
changeset
|
75 /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
|
76 |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
77 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
78 # 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
|
79 # |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
80 CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \ |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
81 "/var/lib/postgresql/9.4/main", "-c", \ |
13d5b6c67cef
Add Dockerfile for Postgres-DB setup.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
82 "config_file=/etc/postgresql/9.4/main/postgresql.conf"] |