Skip to content

Instantly share code, notes, and snippets.

@dbaston
Created March 29, 2016 14:51
Show Gist options
  • Save dbaston/70a2d94802cb0a19afa3 to your computer and use it in GitHub Desktop.
Save dbaston/70a2d94802cb0a19afa3 to your computer and use it in GitHub Desktop.
Dockerfile to build pramsey's parallel PostGIS branch against Postgres/GEOS trunk
FROM phusion/baseimage
RUN apt-get update && apt-get install -y \
build-essential \
git \
bison \
flex \
zlib1g-dev \
autoconf \
libtool \
libjson0-dev \
libxml2-dev \
libproj-dev \
wget \
unzip
RUN git clone --depth 1 https://github.com/postgres/postgres.git && cd postgres && ./configure --without-readline && make && make install && cd .. && rm -rf postgres
RUN git clone --depth 1 https://github.com/libgeos/libgeos.git && cd libgeos && ./autogen.sh && ./configure && make && make install && cd .. && rm -rf libgeos
RUN git clone --branch parallel --depth 1 https://github.com/pramsey/postgis.git && cd postgis && ./autogen.sh && ./configure --without-raster --without-topology --with-pgconfig=/usr/local/pgsql/bin/pg_config && make && make install && cd .. && rm -rf postgis
RUN useradd -ms /bin/bash postgres
RUN ldconfig
USER postgres
RUN mkdir /home/postgres/pgdata && /usr/local/pgsql/bin/initdb -E UTF8 -D /home/postgres/pgdata
RUN echo "host all all 0.0.0.0/0 trust" >> /home/postgres/pgdata/pg_hba.conf && \
echo "listen_addresses='*'" >> /home/postgres/pgdata/postgresql.conf
RUN /usr/local/pgsql/bin/pg_ctl start -w -D /home/postgres/pgdata && \
/usr/local/pgsql/bin/psql -q -v ON_ERROR_STOP=1 < /usr/local/pgsql/share/contrib/postgis-2.3/postgis.sql && \
/usr/local/pgsql/bin/psql -q -v ON_ERROR_STOP=1 < /usr/local/pgsql/share/contrib/postgis-2.3/spatial_ref_sys.sql && \
/usr/local/pgsql/bin/pg_ctl stop -D /home/postgres/pgdata
# Load example data
WORKDIR /home/postgres
RUN wget --quiet http://ftp2.cits.rncan.gc.ca/pub/geott/electoral/2015/pd338.2015.zip && \
unzip pd338.2015.zip -d pd && \
/usr/local/pgsql/bin/pg_ctl start -w -D /home/postgres/pgdata && \
/usr/local/pgsql/bin/shp2pgsql -s 3347 -I -D -W latin1 pd/PD_A.shp pd | /usr/local/pgsql/bin/psql && \
/usr/local/pgsql/bin/pg_ctl stop -D /home/postgres/pgdata && \
rm pd338.2015.zip && rm -rf pd
EXPOSE 5432
CMD /usr/local/pgsql/bin/postgres -D /home/postgres/pgdata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment