raimund@1306: # Docker file for postgresql 9.5 on debain 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@743: # Use user postgres to run the next commands tom@743: # tom@743: USER postgres tom@743: tom@743: RUN /etc/init.d/postgresql start && \ tom@743: psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';" 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@743: raimund@1306: RUN echo "listen_addresses='*'" >> /etc/postgresql/9.5/main/postgresql.conf 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@743: ADD . /opt/lada_sql/ tom@1086: WORKDIR /opt/lada_sql/ tom@743: raimund@1306: RUN /usr/lib/postgresql/9.5/bin/pg_ctl start -wD /etc/postgresql/9.5/main/ && \ tom@743: /opt/lada_sql/setup-db.sh tom@743: tom@743: # tom@743: # Set the default command to run when starting the container tom@743: # raimund@1306: CMD ["/usr/lib/postgresql/9.5/bin/postgres", "-D", \ raimund@1306: "/var/lib/postgresql/9.5/main", "-c", \ raimund@1306: "config_file=/etc/postgresql/9.5/main/postgresql.conf"]