HOST_PORT=8081
DB_PORT=3306
DB_HOST=172.17.0.1
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_ROOT_PASSWORD=
DATA_DIR=/home/docker/data/wizard
ENV_FILE=/home/docker/env/wizard.env
mkdir -p /home/docker/{conf,data,logs,db,env}
mkdir -p ${DATA_DIR}

cat>${ENV_FILE}<<EOF
DB_PORT=3306
DB_HOST=172.17.0.1
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
EOF

mysql -uroot -p${DB_ROOT_PASSWORD} \
-e "create database ${DB_DATABASE};
	grant all privileges on ${DB_DATABASE}.* to ${DB_USERNAME}@'172.17.%' identified by '${DB_PASSWORD}';
	flush privileges;"

docker run -dit --name docs --env-file=${ENV_FILE} -p ${HOST_PORT}:80 \
-v ${DATA_DIR}:/webroot/storage/app/public --restart=unless-stopped \
 mylxsw/wizard

docker exec -ti docs php artisan migrate:install
docker exec -ti docs php artisan migrate