Mercurial > gemma
annotate docker/Dockerfile.pg @ 4165:8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 05 Aug 2019 13:51:08 +0200 |
parents | |
children | 8d6f43894f09 |
rev | line source |
---|---|
4165
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
1 FROM ubuntu:bionic |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
2 LABEL authors="tom.gottfried@intevation.de" |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
3 LABEL description="Contains software from gemma, for right holders and\ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
4 licensing infos, see https://hg.intevation.de/gemma ." |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
5 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
6 ENV DEBIAN_FRONTEND noninteractive |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
7 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
8 RUN apt-get update &&\ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
9 apt-get -y install git make gcc libreadline-dev zlib1g-dev flex bison |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
10 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
11 # Add PostgreSQL's repository |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
12 WORKDIR /opt/ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
13 RUN git clone git://git.postgresql.org/git/postgresql.git |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
14 WORKDIR /opt/postgresql |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
15 RUN git checkout REL_11_STABLE |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
16 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
17 ENV PGDATA /usr/local/pgsql/data |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
18 ENV PGBIN /usr/local/pgsql/bin |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
19 ENV PGCONF /usr/local/pgsql/data/postgresql.conf |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
20 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
21 # Install PostgreSQL from sources |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
22 RUN ./configure && make && make install |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
23 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
24 # Install PostGIS dependencies |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
25 RUN apt-get -y install autoconf xsltproc \ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
26 libproj-dev libgeos-dev libxml2-dev libjson-c-dev libgdal-dev |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
27 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
28 # Add PostGIS repository and build it |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
29 WORKDIR /opt/ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
30 RUN git clone https://git.osgeo.org/gitea/postgis/postgis.git |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
31 WORKDIR /opt/postgis |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
32 RUN git checkout svn-2.5 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
33 RUN ./autogen.sh && ./configure --with-pgconfig=$PGBIN/pg_config && \ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
34 make comments && make && make install |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
35 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
36 # Build btree_gist extension |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
37 WORKDIR /opt/postgresql/contrib/btree_gist |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
38 RUN make && make install |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
39 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
40 # Put PostgreSQL executables in path |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
41 ENV PATH $PGBIN:$PATH |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
42 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
43 # Initialize cluster |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
44 RUN mkdir -p $PGDATA && useradd postgres -d $PGDATA && chown postgres $PGDATA |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
45 USER postgres |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
46 RUN $PGBIN/initdb -D $PGDATA |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
47 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
48 RUN \ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
49 # Adjust PostgreSQL configuration to allow remote connections |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
50 echo "host all all 0.0.0.0/0 md5" \ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
51 >> /usr/local/pgsql/data/pg_hba.conf &&\ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
52 echo "listen_addresses='*'" >> $PGCONF &&\ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
53 # Set port to standard value |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
54 sed -i '/port/s/543./5432/' $PGCONF &&\ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
55 # Keep log on stderr to be able to use docker logs |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
56 sed -i '/logging_collector/s/on/off/' $PGCONF |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
57 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
58 # Expose the PostgreSQL port |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
59 EXPOSE 5432 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
60 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
61 # Create GEMMA role and database |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
62 WORKDIR /opt/gemma |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
63 COPY schema/*.sql schema/*.sh ./ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
64 COPY schema/demo-data ./demo-data/ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
65 RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
66 PATH=$PGBIN:$PATH ./install-db.sh --demo --metapw "geo2Serv" && \ |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
67 $PGBIN/pg_ctl stop -m smart |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
68 |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
69 # Set the default command to run when starting the container |
8dd59e2c9d3d
Add Dockerfile for testing with upstream PostgreSQL/PostGIS
Tom Gottfried <tom@intevation.de>
parents:
diff
changeset
|
70 CMD ["/usr/local/pgsql/bin/postgres", "-D", "/usr/local/pgsql/data"] |