add migration to entrypoint

This commit is contained in:
Sam
2016-09-29 07:51:33 +02:00
parent 64f7c71fde
commit a1037c8459
3 changed files with 28 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ RUN curl -o invoiceninja.tar.gz -SL https://github.com/hillelcoren/invoice-ninja
&& chown -R www-data:www-data /var/www/app \
&& composer install --working-dir /var/www/app -o --no-dev --no-interaction --no-progress \
&& chown -R www-data:www-data /var/www/app/bootstrap/cache \
# && echo ${INVOICENINJA_VERSION} > /var/www/app/storage/version.txt \
&& mv /var/www/app/storage /var/www/app/docker-backup-storage \
&& mv /var/www/app/public/logo /var/www/app/docker-backup-public-logo

View File

@@ -35,8 +35,31 @@ else
fi
chown www-data:www-data /var/www/app/.env
# php artisan optimize --force
# php artisan migrate --force
# php artisan db:seed --class=UpdateSeeder
# widely inspired from https://github.com/docker-library/wordpress/blob/c674e9ceedf582705e0ad8487c16b42b37a5e9da/fpm/docker-entrypoint.sh#L128
TERM=dumb php -- "$DB_HOST" "$DB_USERNAME" "$DB_PASSWORD" "$DB_DATABASE" <<'EOPHP'
<?php
$stderr = fopen('php://stderr', 'w');
list($host, $port) = explode(':', $argv[1], 2);
$maxTries = 20;
do {
try {
$connection = new Pdo("mysql:dbname={$argv[4]};host={$host};port={$port}", $argv[2], $argv[3]);
fwrite($stderr, 'MySQL ready'. "\n");
exit(0);
} catch (PDOException $e) {
fwrite($stderr, 'MySQL Connection Error: ' . $e->getMessage(). "\n");
if (--$maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (true);
EOPHP
php artisan optimize --force
php artisan migrate --force
php artisan db:seed --force
echo 'start'
exec "$@"

View File

@@ -30,7 +30,7 @@ cron:
entrypoint: |
bash -c 'bash -s <<EOF
trap "break;exit" SIGHUP SIGINT SIGTERM
sleep 30s
sleep 300s
while /bin/true; do
DB_USERNAME=root DB_PASSWORD=mdp /usr/local/bin/php /var/www/app/artisan ninja:send-invoices
DB_USERNAME=root DB_PASSWORD=mdp /usr/local/bin/php /var/www/app/artisan ninja:send-reminders