comparison schema/Dockerfile @ 156:4ade330e571e

refactor: Refactor Dockerfile to reflect changes Tighten the run commands to streamline container build Include actual demousers.
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 03 Jul 2018 11:40:16 +0200
parents dad6cf39691e
children a85c44438d48
comparison
equal deleted inserted replaced
155:399357bc205e 156:4ade330e571e
1 FROM centos:7 1 FROM centos:7
2 MAINTAINER tom.gottfried@intevation.de 2 MAINTAINER tom.gottfried@intevation.de
3 3
4 # Add the PostgreSQL PGP key to verify the official yum repository packages 4 # Add the PostgreSQL PGP key to verify the official yum repository packages
5 RUN rpm --import https://yum.postgresql.org/RPM-GPG-KEY-PGDG-10 5 RUN rpm --import https://yum.postgresql.org/RPM-GPG-KEY-PGDG-10 &&\
6
7 # Add PostgreSQL's repository. It contains the most recent release 6 # Add PostgreSQL's repository. It contains the most recent release
8 # of PostgreSQL, 10: 7 # of PostgreSQL, 10:
9 RUN yum -q -y install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm 8 yum -q -y install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm &&\
10
11 # Install PostgreSQL 10 and PostGIS 9 # Install PostgreSQL 10 and PostGIS
12 RUN yum -q -y install postgresql10-server 10 yum -q -y install postgresql10-server &&\
13 RUN yum -q -y install epel-release 11 yum -q -y install epel-release &&\
14 RUN yum -q -y install postgis24_10 pgtap10 12 yum -q -y install postgis24_10 pgtap10
15
16 USER postgres 13 USER postgres
17 ENV PGBIN /usr/pgsql-10/bin/ 14 ENV PGBIN /usr/pgsql-10/bin/
18 15
19 # initdb PostgreSQL 10: 16 # initdb PostgreSQL 10:
20 ENV PGDATA /var/lib/pgsql/10/data 17 ENV PGDATA /var/lib/pgsql/10/data
21 RUN $PGBIN/initdb -E UTF8 2>&1 < /dev/null 18 ENV PGCONF /var/lib/pgsql/10/data/postgresql.conf
22 19 RUN $PGBIN/initdb -E UTF8 2>&1 < /dev/null &&\
23 # Adjust PostgreSQL configuration so that remote connections to the 20 # Adjust PostgreSQL configuration so that remote connections to the
24 # database are possible. 21 # database are possible.
25 ENV PGCONF /var/lib/pgsql/10/data/postgresql.conf 22 echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/10/data/pg_hba.conf &&\
26 RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/10/data/pg_hba.conf 23 echo "listen_addresses='*'" >> $PGCONF
27 RUN echo "listen_addresses='*'" >> $PGCONF
28
29 # Expose the PostgreSQL port 24 # Expose the PostgreSQL port
30 EXPOSE 5432 25 EXPOSE 5432
31 26
32 # Create GEMMA role and database 27 # Create GEMMA role and database
33 ADD *.sql ./ 28 COPY *.sql ./
29 COPY demo-data/*.sql ./
34 RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \ 30 RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \
35 psql -c "CREATE USER gemma PASSWORD 'gemma'" && \ 31 psql -c "CREATE USER gemma PASSWORD 'gemma'" && \
36 createdb gemma && \ 32 createdb gemma && \
37 psql -f gemma.sql -d gemma && \ 33 psql -f gemma.sql -d gemma && \
38 psql -f auth.sql -d gemma && \ 34 psql -f auth.sql -d gemma && \
35 psql -f users.sql -d gemma && \
36 psql -f responsibility_areas.sql -d gemma && \
39 $PGBIN/pg_ctl stop -m smart 37 $PGBIN/pg_ctl stop -m smart
40 38
41 # Set the default command to run when starting the container 39 # Set the default command to run when starting the container
42 CMD ["/usr/pgsql-10/bin/postgres", "-D", "/var/lib/pgsql/10/data"] 40 CMD ["/usr/pgsql-10/bin/postgres", "-D", "/var/lib/pgsql/10/data"]