mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-02-03 15:36:17 +00:00
Adjustment in Docker stuff to work with new migration. Add init_data.py script to initialize table data
This commit is contained in:
parent
ab0124b3e2
commit
232d39cca0
@ -30,6 +30,7 @@ services:
|
|||||||
- PDA_DB_PASSWORD=${PDA_DB_PASSWORD}
|
- PDA_DB_PASSWORD=${PDA_DB_PASSWORD}
|
||||||
- PDNS_HOST=${PDNS_HOST}
|
- PDNS_HOST=${PDNS_HOST}
|
||||||
- PDNS_API_KEY=${PDNS_API_KEY}
|
- PDNS_API_KEY=${PDNS_API_KEY}
|
||||||
|
- FLASK_APP=/powerdns-admin/app/__init__.py
|
||||||
depends_on:
|
depends_on:
|
||||||
powerdns-admin-mysql:
|
powerdns-admin-mysql:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
FROM ubuntu:latest
|
FROM ubuntu:latest
|
||||||
MAINTAINER Khanh Ngo "ngokhanhit@gmail.com"
|
MAINTAINER Khanh Ngo "k@ndk.name"
|
||||||
ARG ENVIRONMENT=development
|
ARG ENVIRONMENT=development
|
||||||
ENV ENVIRONMENT=${ENVIRONMENT}
|
ENV ENVIRONMENT=${ENVIRONMENT}
|
||||||
|
|
||||||
WORKDIR /powerdns-admin
|
WORKDIR /powerdns-admin
|
||||||
|
|
||||||
RUN apt-get update -y
|
RUN apt-get update -y
|
||||||
|
|
||||||
|
RUN apt-get install -y locales locales-all
|
||||||
|
ENV LC_ALL en_US.UTF-8
|
||||||
|
ENV LANG en_US.UTF-8
|
||||||
|
ENV LANGUAGE en_US.UTF-8
|
||||||
|
|
||||||
RUN apt-get install -y python3-pip python3-dev supervisor
|
RUN apt-get install -y python3-pip python3-dev supervisor
|
||||||
|
|
||||||
# lib for building mysql db driver
|
# lib for building mysql db driver
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd /powerdns-admin && ./create_db.py
|
|
||||||
|
if [ ! -d "/powerdns-admin/migrations" ]; then
|
||||||
|
/usr/local/bin/flask db init --directory /powerdns-admin/migrations
|
||||||
|
/usr/local/bin/flask db migrate -m "Init DB" --directory /powerdns-admin/migrations
|
||||||
|
/usr/local/bin/flask db upgrade --directory /powerdns-admin/migrations
|
||||||
|
cd /powerdns-admin && ./init_data.py
|
||||||
|
|
||||||
|
else
|
||||||
|
/usr/local/bin/flask db migrate -m "Upgrade BD Schema" --directory /powerdns-admin/migrations
|
||||||
|
/usr/local/bin/flask db upgrade --directory /powerdns-admin/migrations
|
||||||
|
fi
|
||||||
|
|
||||||
/usr/bin/supervisord -c /etc/supervisord.conf
|
/usr/bin/supervisord -c /etc/supervisord.conf
|
||||||
|
36
init_data.py
Executable file
36
init_data.py
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from app import app, db
|
||||||
|
from app.models import Role, Setting, DomainTemplate
|
||||||
|
|
||||||
|
admin_role = Role(name='Administrator', description='Administrator')
|
||||||
|
user_role = Role(name='User', description='User')
|
||||||
|
|
||||||
|
setting_1 = Setting(name='maintenance', value='False')
|
||||||
|
setting_2 = Setting(name='fullscreen_layout', value='True')
|
||||||
|
setting_3 = Setting(name='record_helper', value='True')
|
||||||
|
setting_4 = Setting(name='login_ldap_first', value='True')
|
||||||
|
setting_5 = Setting(name='default_record_table_size', value='15')
|
||||||
|
setting_6 = Setting(name='default_domain_table_size', value='10')
|
||||||
|
setting_7 = Setting(name='auto_ptr', value='False')
|
||||||
|
|
||||||
|
template_1 = DomainTemplate(name='basic_template_1', description='Basic Template #1')
|
||||||
|
template_2 = DomainTemplate(name='basic_template_2', description='Basic Template #2')
|
||||||
|
template_3 = DomainTemplate(name='basic_template_3', description='Basic Template #3')
|
||||||
|
|
||||||
|
db.session.add(admin_role)
|
||||||
|
db.session.add(user_role)
|
||||||
|
|
||||||
|
db.session.add(setting_1)
|
||||||
|
db.session.add(setting_2)
|
||||||
|
db.session.add(setting_3)
|
||||||
|
db.session.add(setting_4)
|
||||||
|
db.session.add(setting_5)
|
||||||
|
db.session.add(setting_6)
|
||||||
|
db.session.add(setting_7)
|
||||||
|
|
||||||
|
db.session.add(template_1)
|
||||||
|
db.session.add(template_2)
|
||||||
|
db.session.add(template_3)
|
||||||
|
|
||||||
|
db.session.commit()
|
Loading…
x
Reference in New Issue
Block a user