gernotbelger@9030: # Docker file for postgresql 9.4 on debain gernotbelger@9030: # gernotbelger@9030: # build with e.g. `docker build --force-rm=true -t d4e/river_db .', gernotbelger@9030: # then run with e.g. gernotbelger@9030: # `docker run --name d4eriver_db -dp 2345:63333 d4e/river_db:latest' gernotbelger@9030: # gernotbelger@9030: gernotbelger@9030: FROM debian:jessie gernotbelger@9030: MAINTAINER tom@intevation.de gernotbelger@9030: gernotbelger@9030: # gernotbelger@9030: # Use utf-8 gernotbelger@9030: # gernotbelger@9030: RUN echo \ gernotbelger@9030: "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \ gernotbelger@9030: debconf-set-selections && \ gernotbelger@9030: echo "locales locales/default_environment_locale select en_US.UTF-8" | \ gernotbelger@9030: debconf-set-selections gernotbelger@9030: gernotbelger@9030: RUN apt-get update -y && apt-get install -y locales gernotbelger@9030: gernotbelger@9030: ENV LC_ALL en_US.UTF-8 gernotbelger@9030: gernotbelger@9030: # gernotbelger@9030: # Install packages gernotbelger@9030: # gernotbelger@9030: RUN apt-get update && \ gernotbelger@9030: apt-get install -y postgresql-9.4-postgis-2.1 postgis curl gernotbelger@9030: gernotbelger@9030: # gernotbelger@9030: # Use user postgres to run the next commands gernotbelger@9030: # gernotbelger@9030: USER postgres gernotbelger@9030: gernotbelger@9030: RUN /etc/init.d/postgresql start && \ gernotbelger@9030: psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';" gernotbelger@9030: gernotbelger@9030: # gernotbelger@9030: # Adjust PostgreSQL configuration so that remote connections to the gernotbelger@9030: # database are possible. gernotbelger@9030: # gernotbelger@9030: RUN echo "host all all 0.0.0.0/0 md5" >> \ gernotbelger@9030: /etc/postgresql/9.4/main/pg_hba.conf gernotbelger@9030: gernotbelger@9030: ENV PGCONF /etc/postgresql/9.4/main/postgresql.conf gernotbelger@9030: RUN echo "listen_addresses='*'" >> $PGCONF gernotbelger@9030: gernotbelger@9030: # gernotbelger@9030: # Expose the PostgreSQL port gernotbelger@9030: # gernotbelger@9030: EXPOSE 5432 gernotbelger@9030: gernotbelger@9030: # gernotbelger@9030: # Create database gernotbelger@9030: # gernotbelger@9030: # Don't mind scary messages like gernotbelger@9030: # 'FATAL: the database system is starting up'. gernotbelger@9030: # It's because of the -w gernotbelger@9030: # gernotbelger@9030: ADD . /opt/d4eriver_db gernotbelger@9030: gernotbelger@9030: # Go to postgres home for write permissions gernotbelger@9030: WORKDIR /var/lib/postgresql gernotbelger@9030: ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz gernotbelger@9030: RUN curl -k "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \ gernotbelger@9030: tar xz gernotbelger@9030: gernotbelger@9030: ENV PGDATA /var/lib/postgresql/9.4/main gernotbelger@9030: RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wo "--config_file=$PGCONF" && \ gernotbelger@9030: /opt/d4eriver_db/postgresql-setup.sh && \ gernotbelger@9030: psql -f demodaten/d4e_demodata.dump.sql d4e && \ gernotbelger@9030: createuser -S -D -R seddb && \ gernotbelger@9030: createdb seddb && \ gernotbelger@9030: psql -f demodaten/seddb_demodata.dump.sql seddb && \ gernotbelger@9030: /usr/lib/postgresql/9.4/bin/pg_ctl stop gernotbelger@9030: gernotbelger@9030: # gernotbelger@9030: # Set the default command to run when starting the container gernotbelger@9030: # gernotbelger@9030: CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \ gernotbelger@9030: "/var/lib/postgresql/9.4/main", "-c", \ gernotbelger@9030: "config_file=/etc/postgresql/9.4/main/postgresql.conf"]