comparison docker/Dockerfile.db @ 9684:537fe44f2792 3.2.x

Add basic Docker setup for development
author Tom Gottfried <tom@intevation.de>
date Thu, 30 Jul 2020 19:00:44 +0200
parents backend/doc/schema/Dockerfile@8927ec8a3c32
children c3afc0274bba
comparison
equal deleted inserted replaced
9681:8e5a8430b89c 9684:537fe44f2792
1 # Docker file for postgresql 9.4 on debain
2
3 FROM debian:jessie
4 MAINTAINER tom@intevation.de
5
6 #
7 # Use utf-8
8 #
9 RUN echo \
10 "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \
11 debconf-set-selections && \
12 echo "locales locales/default_environment_locale select en_US.UTF-8" | \
13 debconf-set-selections
14
15 RUN apt-get update -y && apt-get install -y locales
16
17 ENV LC_ALL en_US.UTF-8
18
19 #
20 # Install packages
21 #
22 RUN apt-get update && \
23 apt-get install -y postgresql-9.4-postgis-2.1 postgis curl
24
25 #
26 # Use user postgres to run the next commands
27 #
28 USER postgres
29
30 RUN /etc/init.d/postgresql start && \
31 psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';"
32
33 #
34 # Adjust PostgreSQL configuration so that remote connections to the
35 # database are possible.
36 #
37 RUN echo "host all all 0.0.0.0/0 md5" >> \
38 /etc/postgresql/9.4/main/pg_hba.conf
39
40 ENV PGCONF /etc/postgresql/9.4/main/postgresql.conf
41 RUN echo "listen_addresses='*'" >> $PGCONF
42
43 #
44 # Expose the PostgreSQL port
45 #
46 EXPOSE 5432
47
48 #
49 # Create database
50 #
51 # Don't mind scary messages like
52 # 'FATAL: the database system is starting up'.
53 # It's because of the -w
54 #
55 ADD ./backend/doc/schema /opt/d4eriver_db
56
57 # 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 RUN curl -k "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \
61 tar xz
62
63 ENV PGDATA /var/lib/postgresql/9.4/main
64 RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wo "--config_file=$PGCONF" && \
65 /opt/d4eriver_db/postgresql-setup.sh && \
66 psql -f demodaten/d4e_demodata.dump.sql d4e && \
67 createuser -S -D -R seddb && \
68 psql -c "ALTER USER seddb WITH PASSWORD 'seddb'" && \
69 createdb seddb && \
70 psql -f demodaten/seddb_demodata.dump.sql 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
73
74 #
75 # Set the default command to run when starting the container
76 #
77 CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \
78 "/var/lib/postgresql/9.4/main", "-c", \
79 "config_file=/etc/postgresql/9.4/main/postgresql.conf"]

http://dive4elements.wald.intevation.org