dbprepare: create panel tabels + refactor

This commit is contained in:
boyska 2018-09-30 11:39:49 +02:00
parent b23df82c75
commit ecfa79d654

17
dodo.py
View file

@ -18,6 +18,7 @@ def task_build():
'uptodate': [up2date_anyimages], 'uptodate': [up2date_anyimages],
'file_dep': ['docker-compose.yml', 'file_dep': ['docker-compose.yml',
'rss-bridge/Dockerfile', 'rss-bridge/Dockerfile',
'panel/Dockerfile',
] + list(scan_dir('docker')), ] + list(scan_dir('docker')),
'actions': [COMPOSE + ' build'], 'actions': [COMPOSE + ' build'],
'clean': [run_task_func(task__build_rm), 'clean': [run_task_func(task__build_rm),
@ -67,23 +68,23 @@ def stop():
def task_dbprepare(): def task_dbprepare():
'''applica il dump sql al container del db''' '''applica il dump sql al container del db'''
panelcli = 'docker-compose -p feedati exec -T panel ./panelcli -db-pass panelpass -db-addr db:5432 '
psql = r'docker exec -i $(docker ps -aqf name=feedati_db) env PGPASSWORD=superpass psql -h 127.0.0.1 -f - -d feeds superadmin '
return { return {
'setup': ['_dbprepare_clean', 'build'], 'setup': ['_dbprepare_clean', 'build'],
'file_dep': list(scan_dir('docker', '*.sql')), 'file_dep': list(scan_dir('docker', '*.sql')),
'actions': [ 'actions': [
(COMPOSE + ' up -d db').split(), (COMPOSE + ' up -d db panel').split(),
(wait_net_service, ('localhost', 5432, 300)), (wait_net_service, ('localhost', 5432, 300)),
(wait_pgsql_db, ('feedati_db', 'feeds', 'superadmin')), (wait_pgsql_db, ('feedati_db', 'feeds', 'superadmin')),
'echo LOADING DB', 'echo LOADING DB',
# dbconf.sql would be better put in /docker-entrypoint-initdb.d/init-user-db.sh # dbconf.sql would be better put in /docker-entrypoint-initdb.d/init-user-db.sh
# (see https://hub.docker.com/r/library/postgres/ ) # (see https://hub.docker.com/r/library/postgres/ )
r'docker exec -i $(docker ps -aqf name=feedati_db) ' psql + ' < docker/dbconf.sql',
'env PGPASSWORD=superpass psql -h 127.0.0.1 -f - -d feeds superadmin < docker/dbconf.sql', psql + ' < docker/ttrss.sql',
r'docker exec -i $(docker ps -aqf name=feedati_db) ' panelcli + 'setup',
'env PGPASSWORD=ttpass psql -h 127.0.0.1 -f - -d feeds ttrss < docker/ttrss.sql', panelcli + 'adduser -password password admin ad@m.in',
'docker run feedati/feedspanel -db-pass panelpass -db-addr db:5432 batch', psql + ' <<< "GRANT SELECT ON TABLE users.users TO \'apache\'"',
r'env PGPASSWORD=ttpass psql -h 127.0.0.1 -f - -d feeds ttrss <<< '
'"GRANT SELECT ON TABLE users.users TO \'apache\'"',
'echo DB RESTORED', 'echo DB RESTORED',
], ],
'teardown': [(stop, [])], 'teardown': [(stop, [])],