diff --git a/scripts/docker-dev/docker-compose.yaml b/scripts/docker-dev/docker-compose.yaml new file mode 100644 index 0000000..896ee05 --- /dev/null +++ b/scripts/docker-dev/docker-compose.yaml @@ -0,0 +1,16 @@ +version: '2' +services: + postgres: + build: "postgres-postgis/" + image: "postgresql-postgis:9.3-2.3" + ports: + - "5432:5432" + expose: + - "5432" + geoserver: + build: "geoserver/" + image: "geoserver-host-postgres:2.9.2" + ports: + - "8080:8080" + links: + - postgres diff --git a/scripts/docker-dev/geoserver/Dockerfile b/scripts/docker-dev/geoserver/Dockerfile new file mode 100644 index 0000000..a528f1f --- /dev/null +++ b/scripts/docker-dev/geoserver/Dockerfile @@ -0,0 +1,8 @@ +# Provides this geoserver image with 'localhost' remapped to the host machine so db requests are made to host port 5432. +from winsent/geoserver:2.9.2 + +ENV TERM=linux + +COPY startup_extra.sh /opt/geoserver/bin/startup_extra.sh +RUN chmod a+x /opt/geoserver/bin/startup_extra.sh +CMD ["/opt/geoserver/bin/startup_extra.sh"] diff --git a/scripts/docker-dev/geoserver/startup_extra.sh b/scripts/docker-dev/geoserver/startup_extra.sh new file mode 100644 index 0000000..a38eafa --- /dev/null +++ b/scripts/docker-dev/geoserver/startup_extra.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "Redirecting container's 'localhost' to container host." + +# Since this docker container is for a developer using a virtualenv on the host, this is a bit of +# a hack so when a database with host 'localhost' in the project settings file +# has its config passed to geoserver it will reference the host the developer expects. +HOST_IP=`ip route | grep default | awk '{ printf "%s",$3 }'` + +cat /etc/hosts | sed "s/127.0.0.1/$HOST_IP/" > /tmp/etc_hosts +cp /tmp/etc_hosts /etc/hosts + +/opt/geoserver/bin/startup.sh diff --git a/scripts/docker-dev/postgres-postgis/Dockerfile b/scripts/docker-dev/postgres-postgis/Dockerfile new file mode 100644 index 0000000..549bf2e --- /dev/null +++ b/scripts/docker-dev/postgres-postgis/Dockerfile @@ -0,0 +1,3 @@ +from mdillon/postgis:9.3 + +COPY init-user-db.sh /docker-entrypoint-initdb.d/init-user-db.sh diff --git a/scripts/docker-dev/postgres-postgis/init-user-db.sh b/scripts/docker-dev/postgres-postgis/init-user-db.sh new file mode 100644 index 0000000..ae487d9 --- /dev/null +++ b/scripts/docker-dev/postgres-postgis/init-user-db.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL + CREATE USER osgeo WITH PASSWORD 'osgeo'; + ALTER USER osgeo WITH SUPERUSER; + CREATE DATABASE osgeo WITH OWNER osgeo; + GRANT ALL PRIVILEGES ON DATABASE osgeo TO osgeo; +EOSQL