add docker-compose with postgres

This commit is contained in:
Linus Miller 2020-08-28 20:10:40 +02:00
parent 7e93845bb1
commit 3c5a05bed4
5 changed files with 58 additions and 13 deletions

20
docker-compose.yml Normal file
View File

@ -0,0 +1,20 @@
version: '3.7'
volumes:
postgres:
services:
postgres:
image: postgres:12-alpine
restart: always
environment:
- POSTGRES_DB=journey
- POSTGRES_USER=journey
- POSTGRES_PASSWORD=journey
- PGDATA=/var/lib/postgresql/data/volume
ports:
- 5432:5432
volumes:
- ./docker/postgres/01-schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
- ./docker/postgres/02-data.sql:/docker-entrypoint-initdb.d/02-data.sql
- postgres:/var/lib/postgresql/data/volume

View File

View File

29
docker/postgres/dump.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
script_dir=$(dirname $(readlink -f "$0"))
SCHEMA=true
DATA=true
while getopts "as" opt; do
case $opt in
"a")
SCHEMA=false
;;
"s")
DATA=false
;;
esac
done
if [ $SCHEMA = "true" ]; then
echo -n "dumping schema..."
docker-compose exec -T postgres pg_dump -U journey -d journey -s -O > $script_dir/01-schema.sql
echo " done!"
fi
if [ $DATA = "true" ]; then
echo -n "dumping data..."
docker-compose exec -T postgres pg_dump -U journey -d journey -a -O > $script_dir/02-data.sql
echo " done!"
fi

View File

@ -1,15 +1,11 @@
'use strict' import env from './env'
const defaults = { export default {
user: 'newseri_supreme', // env var: PGUSER database: 'journey',
database: 'newseri', // env var: PGDATABASE user: 'journey',
password: 'oh-look-it-is-raining-news', // env var: PGPASSWORD password: 'journey',
// host: '192.168.1.11', // Server hosting the postgres database host: env.POSTGRES_HOST,
host: 'hq.bitmill.co', // Server hosting the postgres database port: 5432,
// port: 5432, // env var: PGPORT idleTimeoutMillis: 30000,
port: 6543, // env var: PGPORT max: 10,
max: 10, // max number of clients in the pool
idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed
} }
module.exports = Object.assign(defaults, {}[ENV])