postgresql with multiple users
This commit is contained in:
parent
952e0270cd
commit
c75aede91b
5 changed files with 20 additions and 11 deletions
|
@ -2,14 +2,14 @@ version: "3.6"
|
|||
|
||||
services:
|
||||
db:
|
||||
image: postgres:10
|
||||
image: postgres:10-alpine
|
||||
container_name: feedati_db
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_USER=ttrss
|
||||
- POSTGRES_PASSWORD=password-dev
|
||||
- POSTGRES_DB=ttrss
|
||||
- POSTGRES_USER=superadmin
|
||||
- POSTGRES_PASSWORD=superpass
|
||||
- POSTGRES_DB=feeds
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
|
@ -37,7 +37,7 @@ services:
|
|||
environment:
|
||||
- PHP_DISPLAY_ERRORS=stdout
|
||||
- PHP_DISPLAY_STARTUP_ERROR=1
|
||||
entrypoint: 'wait-db php7 /app/public/tt-rss/update.php --daemon'
|
||||
entrypoint: 'env PGHOST=db PGDATABASE=feeds PGUSER=ttrss PGPASSWORD=ttpass wait-db php7 /app/public/tt-rss/update.php --daemon'
|
||||
ports: []
|
||||
depends_on:
|
||||
- db
|
||||
|
|
3
docker/dbconf.sql
Normal file
3
docker/dbconf.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
CREATE USER ttrss WITH PASSWORD 'ttpass';
|
||||
CREATE USER panel WITH PASSWORD 'panelpass';
|
|
@ -6,8 +6,8 @@
|
|||
define('DB_TYPE', 'pgsql');
|
||||
define('DB_HOST', 'db');
|
||||
define('DB_USER', 'ttrss');
|
||||
define('DB_NAME', 'ttrss');
|
||||
define('DB_PASS', 'password-dev');
|
||||
define('DB_NAME', 'feeds');
|
||||
define('DB_PASS', 'ttpass');
|
||||
define('DB_PORT', '5432');
|
||||
|
||||
define('MYSQL_CHARSET', 'UTF8');
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/bin/bash
|
||||
### psql configuration parameters must be received as environ vars
|
||||
### (PGHOST, PGDATABASE, PGUSER, PGPASSWORD)
|
||||
timeout=60
|
||||
for _ in $(seq 1 "$timeout"); do
|
||||
if env PGPASSWORD=password-dev psql -h db -U ttrss -w ttrss -c "" -q 2> /dev/null; then
|
||||
if psql -w -c "" -q 2> /dev/null; then
|
||||
echo "DB ready"
|
||||
exec "$@"
|
||||
fi
|
||||
|
|
10
dodo.py
10
dodo.py
|
@ -69,14 +69,18 @@ def task_dbprepare():
|
|||
'''applica il dump sql al container del db'''
|
||||
return {
|
||||
'setup': ['_dbprepare_clean', 'build'],
|
||||
'file_dep': ['docker/ttrss.sql'],
|
||||
'file_dep': list(scan_dir('docker', '*.sql')),
|
||||
'actions': [
|
||||
(COMPOSE + ' up -d db').split(),
|
||||
(wait_net_service, ('localhost', 5432, 300)),
|
||||
(wait_pgsql_db, ('feedati_db', 'ttrss', 'ttrss')),
|
||||
(wait_pgsql_db, ('feedati_db', 'feeds', 'superadmin')),
|
||||
'echo LOADING DB',
|
||||
# dbconf.sql would be better put in /docker-entrypoint-initdb.d/init-user-db.sh
|
||||
# (see https://hub.docker.com/r/library/postgres/ )
|
||||
r'docker exec -i $(docker ps -aqf name=feedati_db) '
|
||||
'psql -h 127.0.0.1 -f - -d ttrss ttrss < docker/ttrss.sql',
|
||||
'env PGPASSWORD=superpass psql -h 127.0.0.1 -f - -d feeds superadmin < docker/dbconf.sql',
|
||||
r'docker exec -i $(docker ps -aqf name=feedati_db) '
|
||||
'env PGPASSWORD=ttpass psql -h 127.0.0.1 -f - -d feeds ttrss < docker/ttrss.sql',
|
||||
'echo DB RESTORED',
|
||||
],
|
||||
'teardown': [(stop, [])],
|
||||
|
|
Loading…
Reference in a new issue