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