summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-10-29 14:28:43 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-11-03 15:58:51 +0100
commitde4a9a16977976e2880ac9e49c9acd624c14673d (patch)
tree6dca78ca66421bfbea3734d556343c56a4430d92 /scripts
parent265477632893bdc71db88033d77dfb8bf6da197d (diff)
Add script to boot postgres docker container for development
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/dev-pg-container.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/dev-pg-container.sh b/scripts/dev-pg-container.sh
new file mode 100644
index 0000000..586e8a2
--- /dev/null
+++ b/scripts/dev-pg-container.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+[ -z "$PG_USER" ] && die "Not set: PG_USER"
+[ -z "$PG_PW" ] && die "Not set: PG_PW"
+[ -z "$PG_DB" ] && die "Not set: PG_DB"
+[ -z "$PG_CONTAINER_NAME" ] && die "Not set: PG_CONTAINER_NAME"
+
+docker run \
+ --name ${PG_CONTAINER_NAME} \
+ -e POSTGRES_PASSWORD=${PG_PW} \
+ -p 5432:5432 \
+ -d \
+ --rm \
+ postgres
+
+sleep 2
+docker exec -it ${PG_CONTAINER_NAME} psql -U postgres -c "CREATE USER ${PG_USER} PASSWORD '${PG_PW}' SUPERUSER CREATEDB INHERIT LOGIN"