annotate docker/Dockerfile.db @ 4878:3fc3f1ed8531

Fix build for restrictive UMASK on host Building a database image failed due to insufficient permissions for the postgres user to read and execute files transfered with COPY from the host if these files did not have the necessary file modes set for all users, because files are owned by root by default.
author Tom Gottfried <tom@intevation.de>
date Mon, 27 Jan 2020 15:49:55 +0100
parents a6f18b3ccab1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
1 FROM ubuntu:bionic
157
a85c44438d48 fix: Replaced MAINTAINER by LABEL
Thomas Junk <thomas.junk@intevation.de>
parents: 156
diff changeset
2 LABEL authors="tom.gottfried@intevation.de"
1356
ce24990b3d5c add licensing hint to docker files
Bernhard Reiter <bernhard@intevation.de>
parents: 1108
diff changeset
3 LABEL description="Contains software from gemma, for right holders and\
ce24990b3d5c add licensing hint to docker files
Bernhard Reiter <bernhard@intevation.de>
parents: 1108
diff changeset
4 licensing infos, see https://hg.intevation.de/gemma ."
35
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5
1577
8ed3a8fd2d2f Fix database Dockerfile
Tom Gottfried <tom@intevation.de>
parents: 1356
diff changeset
6 ENV DEBIAN_FRONTEND noninteractive
8ed3a8fd2d2f Fix database Dockerfile
Tom Gottfried <tom@intevation.de>
parents: 1356
diff changeset
7
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
8 RUN apt-get update &&\
1577
8ed3a8fd2d2f Fix database Dockerfile
Tom Gottfried <tom@intevation.de>
parents: 1356
diff changeset
9 apt-get -y install --no-install-recommends curl ca-certificates gnupg
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
10
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
11 # Add PostgreSQL's repository for current PostgreSQL release and extensions:
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
12 RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' \
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
13 >> /etc/apt/sources.list &&\
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
14 curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
1577
8ed3a8fd2d2f Fix database Dockerfile
Tom Gottfried <tom@intevation.de>
parents: 1356
diff changeset
15 apt-key add - &&\
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
16 apt-get update &&\
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
17 apt-get -y install postgresql-11-postgis-2.5 postgresql-11-pgtap
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
18
35
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 USER postgres
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
20 ENV PGBIN /usr/lib/postgresql/11/bin
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
21 ENV PGDATA /var/lib/postgresql/11/main
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
22 ENV PGCONF /etc/postgresql/11/main/postgresql.conf
35
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
24 RUN \
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
25 # Adjust PostgreSQL configuration to allow remote connections
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
26 echo "host all all 0.0.0.0/0 md5" \
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
27 >> /etc/postgresql/11/main/pg_hba.conf &&\
306
70592a18c5c6 Keep log on stderr to be able to use docker logs
Tom Gottfried <tom@intevation.de>
parents: 246
diff changeset
28 echo "listen_addresses='*'" >> $PGCONF &&\
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
29 # Set port to standard value
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
30 sed -i '/port/s/543./5432/' $PGCONF &&\
306
70592a18c5c6 Keep log on stderr to be able to use docker logs
Tom Gottfried <tom@intevation.de>
parents: 246
diff changeset
31 # Keep log on stderr to be able to use docker logs
70592a18c5c6 Keep log on stderr to be able to use docker logs
Tom Gottfried <tom@intevation.de>
parents: 246
diff changeset
32 sed -i '/logging_collector/s/on/off/' $PGCONF
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
33
35
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 # Expose the PostgreSQL port
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 EXPOSE 5432
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36
4878
3fc3f1ed8531 Fix build for restrictive UMASK on host
Tom Gottfried <tom@intevation.de>
parents: 2893
diff changeset
37 # Create GEMMA roles and database
173
2b04de578be0 Use COPY in a way that allows replacing by a volume
Tom Gottfried <tom@intevation.de>
parents: 172
diff changeset
38 WORKDIR /opt/gemma
4878
3fc3f1ed8531 Fix build for restrictive UMASK on host
Tom Gottfried <tom@intevation.de>
parents: 2893
diff changeset
39 COPY --chown=postgres schema/*.sql schema/*.sh ./
3fc3f1ed8531 Fix build for restrictive UMASK on host
Tom Gottfried <tom@intevation.de>
parents: 2893
diff changeset
40 COPY --chown=postgres schema/demo-data ./demo-data/
35
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
41 RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \
2236
32441ac04c7c Reverted accidentally updated Dockerfiles.
Bjoern Schilberg <bjoern@intevation.de>
parents: 2235
diff changeset
42 ./install-db.sh --demo --metapw "geo2Serv" && \
35
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
43 $PGBIN/pg_ctl stop -m smart
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
44
62e14b4d25fc First working draft of schema for bottlenecks.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45 # Set the default command to run when starting the container
1108
5adee8b0e29f Migrate database Dockerfile to bionic and upgrade database
Tom Gottfried <tom@intevation.de>
parents: 524
diff changeset
46 CMD ["/usr/lib/postgresql/11/bin/postgres", "-D", "/etc/postgresql/11/main"]