tom@1327: # Docker file for the LADA database on Debian tom@743: # tom@743: # build with e.g. `docker build --force-rm=true -t koala/lada_db .', tom@743: # then run with e.g. tom@743: # `docker run --name lada_db -dp 2345:5432 koala/lada_db:latest' tom@743: # tom@1086: # For easier testing of schema or example data changes, it can be useful to add tom@1086: # `-v $PWD:/opt/lada_sql/' and run setup-db.sh within the container. tom@1086: # tom@743: tom@743: FROM debian:jessie tom@743: MAINTAINER tom.gottfried@intevation.de tom@743: tom@743: # tom@743: # Use utf-8 tom@743: # tom@743: RUN echo \ tom@743: "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \ tom@743: debconf-set-selections && \ tom@743: echo "locales locales/default_environment_locale select en_US.UTF-8" | \ tom@743: debconf-set-selections tom@743: tom@743: RUN apt-get update -y && apt-get install -y locales tom@743: tom@743: ENV LC_ALL en_US.UTF-8 tom@743: tom@743: # tom@743: # Install packages tom@743: # tom@743: RUN apt-get update && \ raimund@1306: apt-get install -y curl unzip make gcc raimund@1306: RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" \ raimund@1306: >> /etc/apt/sources.list raimund@1306: RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - raimund@1306: RUN apt-get update && \ raimund@1306: apt-get install -y --no-install-recommends \ raimund@1306: postgresql-9.5-postgis-2.3 postgresql-9.5-postgis-scripts postgis tom@743: tom@743: # tom@1327: # Add context as working directory tom@1327: # tom@1327: ADD . /opt/lada_sql/ tom@1327: WORKDIR /opt/lada_sql/ tom@1327: tom@1327: # tom@1327: # Set environment variables tom@1327: # tom@1327: ENV PGCONF /etc/postgresql/9.5/main/postgresql.conf tom@1327: ENV PGDATA /var/lib/postgresql/9.5/main tom@1327: tom@1327: # tom@743: # Use user postgres to run the next commands tom@743: # tom@743: USER postgres tom@743: tom@1326: # XXX: Seems to fail on initdb issued by package installation tom@1326: # (due to /usr/sbin/policy-rc.d ?). tom@1326: # See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739276 tom@1326: RUN mkdir /var/run/postgresql/9.5-main.pg_stat_tmp tom@743: tom@743: # tom@743: # Adjust PostgreSQL configuration so that remote connections to the tom@743: # database are possible. tom@743: # tom@743: RUN echo "host all all 0.0.0.0/0 md5" >> \ raimund@1306: /etc/postgresql/9.5/main/pg_hba.conf tom@1327: RUN echo "listen_addresses='*'" >> $PGCONF tom@743: tom@1327: # tom@1327: # Configure logging collector tom@1327: # (because we use postgres directly in CMD, tom@1327: # the usual collection from stderr does not work) tom@1327: # tom@1327: RUN echo "logging_collector = on" >> $PGCONF tom@1327: RUN echo "log_directory = '/var/log/postgresql'" >> $PGCONF tom@1327: RUN echo "log_filename = 'postgresql-9.5-main.log'" >> $PGCONF tom@743: tom@743: # tom@743: # Expose the PostgreSQL port tom@743: # tom@743: EXPOSE 5432 tom@743: tom@743: # tom@743: # Create database tom@743: # tom@743: # Don't mind scary messages like tom@743: # 'FATAL: the database system is starting up'. tom@743: # It's because of the -w tom@743: # tom@1327: RUN /usr/lib/postgresql/9.5/bin/pg_ctl start -wo "--config_file=$PGCONF" && \ tom@1327: /opt/lada_sql/setup-db.sh && \ tom@1327: /usr/lib/postgresql/9.5/bin/pg_ctl stop tom@743: tom@743: # tom@743: # Set the default command to run when starting the container tom@743: # tom@1327: CMD ["/usr/lib/postgresql/9.5/bin/postgres", \ tom@1327: "--config_file=/etc/postgresql/9.5/main/postgresql.conf"]