Mercurial > lada > lada-server
annotate db_schema/Dockerfile @ 991:ce1ec3cbde54
Make ID for Messregime an integer.
Using VARCHAR(1) has drawbacks such as an empty string being
a valid value.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 01 Jul 2016 17:36:06 +0200 |
parents | c7fcc46c6a57 |
children | 299f4ba86090 |
rev | line source |
---|---|
743
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
1 # Docker file for postgresql 9.4 on debain |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
2 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
3 # build with e.g. `docker build --force-rm=true -t koala/lada_db .', |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 # then run with e.g. |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
5 # `docker run --name lada_db -dp 2345:5432 koala/lada_db:latest' |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
7 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
8 FROM debian:jessie |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
9 MAINTAINER tom.gottfried@intevation.de |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 # Use utf-8 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
14 RUN echo \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
15 "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
16 debconf-set-selections && \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
17 echo "locales locales/default_environment_locale select en_US.UTF-8" | \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
18 debconf-set-selections |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
19 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
20 RUN apt-get update -y && apt-get install -y locales |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
21 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
22 ENV LC_ALL en_US.UTF-8 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
23 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
24 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
25 # Install packages |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
26 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
27 RUN apt-get update && \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
28 apt-get install -y postgresql-9.4-postgis-2.1 postgis |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
29 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
30 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
31 # Use user postgres to run the next commands |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
32 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
33 USER postgres |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
34 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
35 RUN /etc/init.d/postgresql start && \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
36 psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';" |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
37 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
38 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
39 # Adjust PostgreSQL configuration so that remote connections to the |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
40 # database are possible. |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
41 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
42 RUN echo "host all all 0.0.0.0/0 md5" >> \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
43 /etc/postgresql/9.4/main/pg_hba.conf |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
44 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
45 RUN echo "listen_addresses='*'" >> /etc/postgresql/9.4/main/postgresql.conf |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
46 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
47 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
48 # Expose the PostgreSQL port |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
49 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
50 EXPOSE 5432 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
51 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
52 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
53 # Create database |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
54 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
55 # Don't mind scary messages like |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
56 # 'FATAL: the database system is starting up'. |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
57 # It's because of the -w |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
58 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
59 ADD . /opt/lada_sql/ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
60 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
61 RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wD /etc/postgresql/9.4/main/ && \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
62 /opt/lada_sql/setup-db.sh |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
63 |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
64 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
65 # Set the default command to run when starting the container |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
66 # |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
67 CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
68 "/var/lib/postgresql/9.4/main", "-c", \ |
c7fcc46c6a57
Add Dockerfile for dockerised DB-server.
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
69 "config_file=/etc/postgresql/9.4/main/postgresql.conf"] |