add docker-compose with postgres
This commit is contained in:
parent
7e93845bb1
commit
3c5a05bed4
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal 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
|
||||
0
docker/postgres/01-schema.sql
Normal file
0
docker/postgres/01-schema.sql
Normal file
0
docker/postgres/02-data.sql
Normal file
0
docker/postgres/02-data.sql
Normal file
29
docker/postgres/dump.sh
Executable file
29
docker/postgres/dump.sh
Executable 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
|
||||
@ -1,15 +1,11 @@
|
||||
'use strict'
|
||||
import env from './env'
|
||||
|
||||
const defaults = {
|
||||
user: 'newseri_supreme', // env var: PGUSER
|
||||
database: 'newseri', // env var: PGDATABASE
|
||||
password: 'oh-look-it-is-raining-news', // env var: PGPASSWORD
|
||||
// host: '192.168.1.11', // Server hosting the postgres database
|
||||
host: 'hq.bitmill.co', // Server hosting the postgres database
|
||||
// port: 5432, // env var: PGPORT
|
||||
port: 6543, // env var: PGPORT
|
||||
max: 10, // max number of clients in the pool
|
||||
idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed
|
||||
export default {
|
||||
database: 'journey',
|
||||
user: 'journey',
|
||||
password: 'journey',
|
||||
host: env.POSTGRES_HOST,
|
||||
port: 5432,
|
||||
idleTimeoutMillis: 30000,
|
||||
max: 10,
|
||||
}
|
||||
|
||||
module.exports = Object.assign(defaults, {}[ENV])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user