Skip to content

Commit

Permalink
Merge pull request GeoNode#89 from JivanAmara/docker-dev
Browse files Browse the repository at this point in the history
Docker images for postgres & geoserver with docker-compose for developing from a virtualenv.
  • Loading branch information
jj0hns0n authored Jan 6, 2017
2 parents 0aa3272 + 4dc2dd6 commit 369b9f7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/docker-dev/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions scripts/docker-dev/geoserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
12 changes: 12 additions & 0 deletions scripts/docker-dev/geoserver/startup_extra.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions scripts/docker-dev/postgres-postgis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from mdillon/postgis:9.3

COPY init-user-db.sh /docker-entrypoint-initdb.d/init-user-db.sh
9 changes: 9 additions & 0 deletions scripts/docker-dev/postgres-postgis/init-user-db.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 369b9f7

Please sign in to comment.