diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..0701b475 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +# Copy this file to .env +# ---------------------- +# Define POSTGRES PORT for Docker when calling datamodel/scripts/run-docker.sh +SIGNALO_PG_PORT=5432 diff --git a/.gitignore b/.gitignore index aeff93fd..963ff645 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,11 @@ +.env +project/images/_* +project/this-is-the-way.jpg +project/signalo.ts +project/signalo_attachments.zip +website/tx +website/local.html + .idea .DS_Store *.orig @@ -12,13 +20,3 @@ official-signs.json postgresql.jar schemaspy*.jar schemaspy/ -website/local.html -project/this-is-the-way.jpg -project/signalo.ts -project/signalo_attachments.zip -website/tx -Pipfile -Pipfile.lock -.env -Pipfile -project/images/_* diff --git a/scripts/run-docker.sh b/scripts/run-docker.sh index 5074f0dc..9b746d60 100755 --- a/scripts/run-docker.sh +++ b/scripts/run-docker.sh @@ -2,27 +2,47 @@ set -e +# load env vars +# https://stackoverflow.com/a/20909045/1548052 +export $(grep -v '^#' .env | xargs) + BUILD=0 +DEMO_DATA=0 +SIGNALO_PG_PORT=${TWW_PG_PORT:-5432} -while getopts 'b' opt; do +while getopts 'bdp:' opt; do case "$opt" in b) - echo "Processing option 'a'" + echo "Rebuild docker image" BUILD=1 ;; + d) + echo "Load demo data" + DEMO_DATA=1 + ;; + + p) + echo "Overriding PG port to ${OPTARG}" + TWW_PG_PORT=${OPTARG} + ;; + + ?|h) - echo "Usage: $(basename $0) [-b]" + echo "Usage: $(basename $0) [-bd] [-p PG_PORT]" exit 1 ;; esac done shift "$(($OPTIND -1))" + if [[ $BUILD -eq 1 ]]; then docker build -f .docker/Dockerfile --tag opengisch/signalo . fi docker rm -f signalo || true -docker run -d -p 5433:5432 -v $(pwd):/src --name signalo opengisch/signalo -c log_statement=all +docker run -d -p ${SIGNALO_PG_PORT}:5432 -v $(pwd):/src --name signalo opengisch/signalo -c log_statement=all docker exec signalo init_db.sh wait -docker exec signalo init_db.sh build -d +if [[ $DEMO_DATA -eq 1 ]]; then + docker exec signalo init_db.sh build -d +fi