Skip to content

Commit

Permalink
Fixes for a docker-compose working out of the box
Browse files Browse the repository at this point in the history
  • Loading branch information
xakraz committed Jul 6, 2018
1 parent 96a9c12 commit 363a093
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
2 changes: 1 addition & 1 deletion configs/development.py
Expand Up @@ -5,7 +5,7 @@
WTF_CSRF_ENABLED = True
SECRET_KEY = 'changeme'
LOG_LEVEL = 'DEBUG'
LOG_FILE = 'log.txt'
LOG_FILE = 'logs/log.txt'

# TIMEOUT - for large zones
TIMEOUT = 10
Expand Down
22 changes: 18 additions & 4 deletions docker-compose.yml
Expand Up @@ -14,8 +14,14 @@ services:
ports:
- "9191:9191"
volumes:
# Code
- .:/powerdns-admin/
- "./configs/${ENVIRONMENT}.py:/powerdns-admin/config.py"
# Assets dir volume
- powerdns-admin-assets:/powerdns-admin/app/static
- powerdns-admin-assets2:/powerdns-admin/node_modules
- powerdns-admin-assets3:/powerdns-admin/logs
- ./app/static/custom:/powerdns-admin/app/static/custom
logging:
driver: json-file
options:
Expand All @@ -41,8 +47,10 @@ services:
container_name: powerdns-admin-mysql
mem_limit: 256M
memswap_limit: 256M
ports:
- "3306:3306"
expose:
- 3306
volumes:
- powerdns-admin-mysql-data:/var/lib/mysql
networks:
- default
environment:
Expand Down Expand Up @@ -78,8 +86,10 @@ services:
container_name: ${PDNS_DB_HOST}
mem_limit: 256M
memswap_limit: 256M
ports:
- "3307:3306"
expose:
- 3306
volumes:
- powerdns-mysql-data:/var/lib/mysql
networks:
- default
environment:
Expand All @@ -96,3 +106,7 @@ networks:

volumes:
powerdns-mysql-data:
powerdns-admin-mysql-data:
powerdns-admin-assets:
powerdns-admin-assets2:
powerdns-admin-assets3:
48 changes: 38 additions & 10 deletions docker/PowerDNS-Admin/entrypoint.sh
@@ -1,6 +1,17 @@
#!/bin/sh
#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail


# == Vars
#
DB_MIGRATION_DIR='/powerdns-admin/migrations'


# Wait for us to be able to connect to MySQL before proceeding
echo "===> Waiting for $PDA_DB_HOST MySQL service"
until nc -zv \
$PDA_DB_HOST \
3306;
Expand All @@ -9,20 +20,37 @@ do
sleep 1
done


echo "===> DB management"
# Go in Workdir
cd /powerdns-admin

if [ ! -d "/powerdns-admin/migrations" ]; then
flask db init --directory /powerdns-admin/migrations
flask db migrate -m "Init DB" --directory /powerdns-admin/migrations
flask db upgrade --directory /powerdns-admin/migrations
./init_data.py
if [ ! -d "${DB_MIGRATION_DIR}" ]; then
echo "---> Running DB Init"
flask db init --directory ${DB_MIGRATION_DIR}
flask db migrate -m "Init DB" --directory ${DB_MIGRATION_DIR}
flask db upgrade --directory ${DB_MIGRATION_DIR}
./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
echo "---> Running DB Migration"
set +e
flask db migrate -m "Upgrade BD Schema" --directory ${DB_MIGRATION_DIR}
flask db upgrade --directory ${DB_MIGRATION_DIR}
set -e
fi

yarn install --pure-lockfile
flask assets build

echo "===> Assets management"
echo "---> Running Yarn"
chown -R www-data:www-data /powerdns-admin/app/static
chown -R www-data:www-data /powerdns-admin/node_modules
su -s /bin/bash -c 'yarn install --pure-lockfile' www-data

echo "---> Running Flask assets"
chown -R www-data:www-data /powerdns-admin/logs
su -s /bin/bash -c 'flask assets build' www-data


echo "===> Start supervisor"
/usr/bin/supervisord -c /etc/supervisord.conf

0 comments on commit 363a093

Please sign in to comment.