forked from drugis/gemtc-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-db.sh
More file actions
executable file
·25 lines (25 loc) · 862 Bytes
/
Copy pathsetup-db.sh
File metadata and controls
executable file
·25 lines (25 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
# NB assumes a psql database docker container named 'postgres' to already be running. Adjust
# the script if your configuration is different.
# Example db run command: docker run --name postgres -e POSTGRES_PASSWORD=develop -d postgres
# Also, change the passwords if desired.
POSTGRES_PASSWORD=develop
GEMTC_PASSWORD=develop
echo "
postgres:5432:*:postgres:$POSTGRES_PASSWORD
postgres:5432:*:gemtc:$GEMTC_PASSWORD
" > .pgpass
echo "
chmod 0600 root/.pgpass
psql -h postgres -U postgres \
-c \"CREATE USER gemtc WITH PASSWORD '$GEMTC_PASSWORD'\" \
-c \"CREATE DATABASE gemtc ENCODING 'utf-8' OWNER gemtc\"
" > db.sh
chmod a+x db.sh
docker run -it --rm \
--mount type=bind,source="$(pwd)"/.pgpass,target=/root/.pgpass \
--mount type=bind,source="$(pwd)"/db.sh,target=/db.sh \
--link postgres:postgres postgres \
/db.sh
rm db.sh
rm .pgpass