Skip to content

Commit

Permalink
Updated to 9.6 and postgis 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Oct 21, 2017
1 parent 6b830d3 commit 9987840
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@ ENV DEBIAN_FRONTEND noninteractive
RUN dpkg-divert --local --rename --add /sbin/initctl

RUN apt-get -y update
RUN apt-get -y install gnupg
#RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.5``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN apt-get -y install gnupg2 wget ca-certificates rpl pwgen
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get -y update
RUN apt-get -y install ca-certificates rpl pwgen
#RUN apt-get -y upgrade

#-------------Application Specific Stuff ----------------------------------------------------

# We add postgis as well to prevent build errors (that we dont see on local builds)
# on docker hub e.g.
# The following packages have unmet dependencies:
RUN apt-get install -y postgresql-9.5-postgis-2.2
RUN apt-get install -y postgresql-client-9.6 postgresql-common postgresql-9.6 postgresql-9.6-postgis-2.4 postgresql-9.6-pgrouting netcat

# Open port 5432 so linked containers can see them
EXPOSE 5432
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker build -t kartoza/postgis:9.5-2.2 .
docker build -t kartoza/postgis:9.6-2.4 .
12 changes: 6 additions & 6 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
chmod 600 /etc/ssl/private/ssl-cert-snakeoil.key

# These tasks are run as root
CONF="/etc/postgresql/9.5/main/postgresql.conf"
CONF="/etc/postgresql/9.6/main/postgresql.conf"

# Restrict subnet to docker private network
echo "host all all 172.17.0.0/16 md5" >> /etc/postgresql/9.5/main/pg_hba.conf
echo "host all all 172.18.0.0/16 md5" >> /etc/postgresql/9.5/main/pg_hba.conf
echo "host all all 172.17.0.0/16 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
echo "host all all 172.18.0.0/16 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
# And allow access from DockerToolbox / Boottodocker on OSX
echo "host all all 192.168.0.0/16 md5" >> /etc/postgresql/9.5/main/pg_hba.conf
echo "host all all 192.168.0.0/16 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
# Listen on all ip addresses
echo "listen_addresses = '*'" >> /etc/postgresql/9.5/main/postgresql.conf
echo "port = 5432" >> /etc/postgresql/9.5/main/postgresql.conf
echo "listen_addresses = '*'" >> /etc/postgresql/9.6/main/postgresql.conf
echo "port = 5432" >> /etc/postgresql/9.6/main/postgresql.conf

# Enable ssl

Expand Down
20 changes: 10 additions & 10 deletions start-postgis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# This script will run as the postgres user due to the Dockerfile USER directive

DATADIR="/var/lib/postgresql/9.5/main"
CONF="/etc/postgresql/9.5/main/postgresql.conf"
POSTGRES="/usr/lib/postgresql/9.5/bin/postgres"
INITDB="/usr/lib/postgresql/9.5/bin/initdb"
SQLDIR="/usr/share/postgresql/9.5/contrib/postgis-2.2/"
DATADIR="/var/lib/postgresql/9.6/main"
CONF="/etc/postgresql/9.6/main/postgresql.conf"
POSTGRES="/usr/lib/postgresql/9.6/bin/postgres"
INITDB="/usr/lib/postgresql/9.6/bin/initdb"
SQLDIR="/usr/share/postgresql/9.6/contrib/postgis-2.2/"
LOCALONLY="-c listen_addresses='127.0.0.1, ::1'"

# /etc/ssl/private can't be accessed from within container for some reason
Expand All @@ -18,8 +18,8 @@ rm -r /etc/ssl
mv /tmp/ssl-copy /etc/ssl

# Needed under debian, wasnt needed under ubuntu
mkdir -p /var/run/postgresql/9.5-main.pg_stat_tmp
chmod 0777 /var/run/postgresql/9.5-main.pg_stat_tmp
mkdir -p /var/run/postgresql/9.6-main.pg_stat_tmp
chmod 0777 /var/run/postgresql/9.6-main.pg_stat_tmp

# test if DATADIR is existent
if [ ! -d $DATADIR ]; then
Expand Down Expand Up @@ -71,7 +71,7 @@ fi
# Usage is: docker run [...] -e ALLOW_IP_RANGE='192.168.0.0/16'
if [ "$ALLOW_IP_RANGE" ]
then
echo "host all all $ALLOW_IP_RANGE md5" >> /etc/postgresql/9.5/main/pg_hba.conf
echo "host all all $ALLOW_IP_RANGE md5" >> /etc/postgresql/9.6/main/pg_hba.conf
fi

# redirect user/pass into a file so we can echo it into
Expand Down Expand Up @@ -139,11 +139,11 @@ fi
# This should show up in docker logs afterwards
su - postgres -c "psql -l"

PID=`cat /var/run/postgresql/9.5-main.pid`
PID=`cat /var/run/postgresql/9.6-main.pid`
kill -TERM ${PID}

# Wait for background postgres main process to exit
while [ "$(ls -A /var/run/postgresql/9.5-main.pid 2>/dev/null)" ]; do
while [ "$(ls -A /var/run/postgresql/9.6-main.pid 2>/dev/null)" ]; do
sleep 1
done

Expand Down

0 comments on commit 9987840

Please sign in to comment.