Skip to content

Commit

Permalink
add options to define PG port in run-docker.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Nov 22, 2023
1 parent 705200e commit e4b9730
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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
18 changes: 8 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/_*
30 changes: 25 additions & 5 deletions scripts/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e4b9730

Please sign in to comment.