Public Repository

Last pushed: 2 years ago
Short Description
Ubuntu 14.04.2 LTS / PostgreSQL 9.4.4 with BDR 0.9.2 (latest stable) and PostGIS 2.1.8 from Sources
Full Description

Ubuntu 14.04.2 LTS / PostgreSQL 9.4.4 with BDR 0.9.2 (latest stable) and PostGIS 2.1.8 from Sources (tagged: 9.4.2-0.9.2-2.1.8)

Dockerfile

FROM keks/ubuntu
MAINTAINER Jan M. <keks@keksfabrik.eu>
# Install PostgreSQL 9.4 with BDR and postgis from sources
# from http://bdr-project.org/docs/stable/installation-packages.html#INSTALLATION-PACKAGES-DEBIAN
# http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21Ubuntu1404src
ENV POSTGIS_VERSION=2.1.8
ENV POSTGRES_VERSION=9.4

# add keys for psql & pgrouting
RUN wget --quiet -O - http://packages.2ndquadrant.com/bdr/apt/AA7A6805.asc | apt-key add - && \
    echo "deb http://packages.2ndquadrant.com/bdr/apt/ "$(lsb_release -sc)"-2ndquadrant main" >> /etc/apt/sources.list.d/2ndquadrant.list && \
    wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \
    echo "deb http://apt.postgresql.org/pub/repos/apt "$(lsb_release -sc)"-pgdg main" >> /etc/apt/sources.list

# make sure UTF8 is used
RUN locale-gen --no-purge en_US.UTF-8
ENV LC_ALL en_US.UTF-8
RUN update-locale LANG=en_US.UTF-8

# update & install psql 9.4 w/ BDR (-dev package needed for postgis) and postgis dependencies
RUN apt-get update && \
    apt-get install -y -f \
        postgresql-bdr-${POSTGRES_VERSION} \
        postgresql-bdr-server-dev-${POSTGRES_VERSION} \
        postgresql-bdr-client-${POSTGRES_VERSION} \
        postgresql-bdr-contrib-${POSTGRES_VERSION} \
        postgresql-bdr-${POSTGRES_VERSION}-dbg \
        postgresql-bdr-${POSTGRES_VERSION}-bdr-plugin \
        libgeos-c1 libgdal-dev libproj-dev libjson0-dev libxml2-dev libxml2-utils xsltproc docbook-xsl docbook-mathml && \
    rm -rf /var/lib/apt/lists/*

# get latest postgis
RUN wget http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz && \
    tar xfz postgis-${POSTGIS_VERSION}.tar.gz

# now build from sources
RUN cd postgis-${POSTGIS_VERSION} && \
    ./configure && \
    make && \
    make install && \
    ldconfig && \
    make comments-install

# and link so command line tools work
RUN ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql && \
    ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp && \
    ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql

ENV PATH=$PATH:/usr/lib/postgresql/${POSTGRES_VERSION}/bin
# add startup script (will not work as a service without)

ADD run.sh /start-postgis

# make it all runnable/readable for the user
RUN chmod +x /start-postgis && \
    chown postgres:postgres /start-postgis

# everything from now on as the 'postgres' user
USER postgres

# Create a PostgreSQL roles named 'docker' and 'bdr' (replication user) with password 'docker'
# then create a database `bdr` owned by the 'bdr' role.
RUN /etc/init.d/postgresql restart &&\
    psql --command "CREATE ROLE docker WITH SUPERUSER CREATEDB CREATEROLE REPLICATION ENCRYPTED PASSWORD 'docker';" &&\
    psql --command "CREATE ROLE bdr REPLICATION LOGIN ENCRYPTED PASSWORD 'docker';" &&\
    createdb -O bdr --encoding=UTF8 bdr

# Expose the PostgreSQL port
EXPOSE 5432

# Add VOLUMEs to allow backup of config, logs and databases and SSL certificates - see postgresql.conf
VOLUME  ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql", "/cert"]

ENTRYPOINT /start-postgis

PostGIS Database-Cluster with Bi-Directional Replication (BDR, see http://bdr-project.org/docs/stable/) enabled - will apparently be fully included in the PostgreSQL 9.5 or 9.6 Release and otherwise has to be installed from the BDR-projects sources

Content of the run.sh file:


#!/usr/bin/env bash
exec /usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main --config-file=/etc/postgresql/9.4/main/postgresql.conf

WARNING
You currently cannot have both BDR and PostGIS activated on the same DB - the image includes both but so far BDR is unable to replicate some of the actions taken by PostGIS's CREATE EXTENSION postgis; fails so your options are either:

CREATE EXTENSION bdr; and CREATE EXTENSION btree_gist; OR

CREATE EXTENSION postgis;, CREATE EXTENSION postgis_topology;, CREATE EXTENSION fuzzstrmatch; & CREATE EXTENSION postgis_geocoder;

Further configuration can be added by the user :)

also tagged versions: 9.4-0.9-2.1.7 & 9.4.2-0.9.1-2.1.7

Docker Pull Command
Owner
keks

Comments (0)