tom@9734: # Dockerfile providing a PostgreSQL database with example data for D4E River tom@9720: FROM debian:bullseye tom@9720: LABEL maintainer tom.gottfried@intevation.de tom@9720: tom@9720: ENV PG_VERSION 13 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@9720: RUN apt-get install -y postgresql-$PG_VERSION-postgis-3 curl tom@9720: RUN apt-get -y clean tom@9720: tom@9720: ENV PGCONF /etc/postgresql/$PG_VERSION/main/postgresql.conf tom@9720: ENV PGBIN /usr/lib/postgresql/$PG_VERSION/bin/ tom@9720: ENV PGDATA /var/lib/postgresql/$PG_VERSION/main tom@8795: tom@8795: # tom@8795: # Use user postgres to run the next commands tom@8795: # tom@8795: USER postgres 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@9720: /etc/postgresql/$PG_VERSION/main/pg_hba.conf tom@8795: 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@9684: ADD ./backend/doc/schema /opt/d4eriver_db tom@8795: tom@8817: # Go to postgres home for write permissions tom@8817: ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz tom@9720: RUN curl -sf "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \ tom@9720: tar -C $HOME --wildcards -xz 'demodaten/*.dump.sql' tom@8817: tom@9734: # Initialize database tom@9734: # Note that PostGIS legacy.sql is needed to support the outdated MapServer 6 tom@9720: RUN $PGBIN/pg_ctl start -wo "--config_file=$PGCONF" && \ tom@8817: /opt/d4eriver_db/postgresql-setup.sh && \ tom@9720: psql -f ~/demodaten/d4e_demodata.dump.sql d4e && \ tom@9734: psql -d d4e -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-3.1/legacy.sql && \ tom@8817: createuser -S -D -R seddb && \ tom@9684: psql -c "ALTER USER seddb WITH PASSWORD 'seddb'" && \ tom@8817: createdb seddb && \ tom@9720: psql -f ~/demodaten/seddb_demodata.dump.sql seddb && \ tom@9684: psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO seddb" seddb && \ tom@9720: $PGBIN/pg_ctl stop -m smart tom@9720: tom@9720: RUN rm -r ~/demodaten tom@8795: tom@8795: # tom@8795: # Set the default command to run when starting the container tom@8795: # tom@9720: CMD ["/usr/lib/postgresql/13/bin/postgres", "-D", \ tom@9720: "/var/lib/postgresql/13/main", "-c", \ tom@9720: "config_file=/etc/postgresql/13/main/postgresql.conf"]