view docker/Dockerfile.db @ 1577:8ed3a8fd2d2f

Fix database Dockerfile Use DEBIAN_FRONTEND=noninteractive to avoid any debconf interaction, e.g. when configuring tzdata. ca-certificates is needed to fetch the PostgreSQL key via https, but was not explicitly installed. Running as root does not require sudo and it is not explicitly installed.
author Tom Gottfried <tom@intevation.de>
date Thu, 13 Dec 2018 14:22:47 +0100
parents ce24990b3d5c
children 39586a34979c
line wrap: on
line source

FROM ubuntu:bionic
LABEL authors="tom.gottfried@intevation.de"
LABEL description="Contains software from gemma, for right holders and\
 licensing infos, see https://hg.intevation.de/gemma ."

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update &&\
    apt-get -y install --no-install-recommends curl ca-certificates gnupg

# Add PostgreSQL's repository for current PostgreSQL release and extensions:
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' \
    >> /etc/apt/sources.list &&\
    curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
    apt-key add - &&\
    apt-get update &&\
    apt-get -y install postgresql-11-postgis-2.5 postgresql-11-pgtap

USER postgres
ENV PGBIN /usr/lib/postgresql/11/bin
ENV PGDATA /var/lib/postgresql/11/main
ENV PGCONF /etc/postgresql/11/main/postgresql.conf

RUN \
    # Adjust PostgreSQL configuration to allow remote connections
    echo "host all  all    0.0.0.0/0  md5" \
         >> /etc/postgresql/11/main/pg_hba.conf &&\
    echo "listen_addresses='*'" >> $PGCONF &&\
    # Set port to standard value
    sed -i '/port/s/543./5432/' $PGCONF &&\
    # Keep log on stderr to be able to use docker logs
    sed -i '/logging_collector/s/on/off/' $PGCONF

# Expose the PostgreSQL port
EXPOSE 5432

# Create GEMMA role and database
WORKDIR /opt/gemma
COPY schema/*.sql schema/*.sh ./
COPY schema/demo-data ./demo-data/
RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \
    ./install-db.sh --demo --metapw "geo2Serv" && \
    $PGBIN/pg_ctl stop -m smart

# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/11/bin/postgres", "-D", "/etc/postgresql/11/main"]