Mercurial > lada > lada-server
comparison db_schema/Dockerfile @ 1327:f2e574204e38
Graft some improvements to dockerised PostgreSQL from rev ea6b062e5305.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 27 Mar 2017 15:25:27 +0200 |
parents | 5a62a68bccf5 |
children |
comparison
equal
deleted
inserted
replaced
1326:5a62a68bccf5 | 1327:f2e574204e38 |
---|---|
1 # Docker file for postgresql 9.5 on debain | 1 # Docker file for the LADA database on Debian |
2 # | 2 # |
3 # build with e.g. `docker build --force-rm=true -t koala/lada_db .', | 3 # build with e.g. `docker build --force-rm=true -t koala/lada_db .', |
4 # then run with e.g. | 4 # then run with e.g. |
5 # `docker run --name lada_db -dp 2345:5432 koala/lada_db:latest' | 5 # `docker run --name lada_db -dp 2345:5432 koala/lada_db:latest' |
6 # | 6 # |
35 RUN apt-get update && \ | 35 RUN apt-get update && \ |
36 apt-get install -y --no-install-recommends \ | 36 apt-get install -y --no-install-recommends \ |
37 postgresql-9.5-postgis-2.3 postgresql-9.5-postgis-scripts postgis | 37 postgresql-9.5-postgis-2.3 postgresql-9.5-postgis-scripts postgis |
38 | 38 |
39 # | 39 # |
40 # Add context as working directory | |
41 # | |
42 ADD . /opt/lada_sql/ | |
43 WORKDIR /opt/lada_sql/ | |
44 | |
45 # | |
46 # Set environment variables | |
47 # | |
48 ENV PGCONF /etc/postgresql/9.5/main/postgresql.conf | |
49 ENV PGDATA /var/lib/postgresql/9.5/main | |
50 | |
51 # | |
40 # Use user postgres to run the next commands | 52 # Use user postgres to run the next commands |
41 # | 53 # |
42 USER postgres | 54 USER postgres |
43 | 55 |
44 # XXX: Seems to fail on initdb issued by package installation | 56 # XXX: Seems to fail on initdb issued by package installation |
50 # Adjust PostgreSQL configuration so that remote connections to the | 62 # Adjust PostgreSQL configuration so that remote connections to the |
51 # database are possible. | 63 # database are possible. |
52 # | 64 # |
53 RUN echo "host all all 0.0.0.0/0 md5" >> \ | 65 RUN echo "host all all 0.0.0.0/0 md5" >> \ |
54 /etc/postgresql/9.5/main/pg_hba.conf | 66 /etc/postgresql/9.5/main/pg_hba.conf |
67 RUN echo "listen_addresses='*'" >> $PGCONF | |
55 | 68 |
56 RUN echo "listen_addresses='*'" >> /etc/postgresql/9.5/main/postgresql.conf | 69 # |
70 # Configure logging collector | |
71 # (because we use postgres directly in CMD, | |
72 # the usual collection from stderr does not work) | |
73 # | |
74 RUN echo "logging_collector = on" >> $PGCONF | |
75 RUN echo "log_directory = '/var/log/postgresql'" >> $PGCONF | |
76 RUN echo "log_filename = 'postgresql-9.5-main.log'" >> $PGCONF | |
57 | 77 |
58 # | 78 # |
59 # Expose the PostgreSQL port | 79 # Expose the PostgreSQL port |
60 # | 80 # |
61 EXPOSE 5432 | 81 EXPOSE 5432 |
65 # | 85 # |
66 # Don't mind scary messages like | 86 # Don't mind scary messages like |
67 # 'FATAL: the database system is starting up'. | 87 # 'FATAL: the database system is starting up'. |
68 # It's because of the -w | 88 # It's because of the -w |
69 # | 89 # |
70 ADD . /opt/lada_sql/ | 90 RUN /usr/lib/postgresql/9.5/bin/pg_ctl start -wo "--config_file=$PGCONF" && \ |
71 WORKDIR /opt/lada_sql/ | 91 /opt/lada_sql/setup-db.sh && \ |
72 | 92 /usr/lib/postgresql/9.5/bin/pg_ctl stop |
73 RUN /usr/lib/postgresql/9.5/bin/pg_ctl start -wD /etc/postgresql/9.5/main/ && \ | |
74 /opt/lada_sql/setup-db.sh | |
75 | 93 |
76 # | 94 # |
77 # Set the default command to run when starting the container | 95 # Set the default command to run when starting the container |
78 # | 96 # |
79 CMD ["/usr/lib/postgresql/9.5/bin/postgres", "-D", \ | 97 CMD ["/usr/lib/postgresql/9.5/bin/postgres", \ |
80 "/var/lib/postgresql/9.5/main", "-c", \ | 98 "--config_file=/etc/postgresql/9.5/main/postgresql.conf"] |
81 "config_file=/etc/postgresql/9.5/main/postgresql.conf"] |