diff --git a/Containerfile b/Containerfile index 59ffdae..be42ebe 100644 --- a/Containerfile +++ b/Containerfile @@ -48,6 +48,7 @@ COPY --from=builder /var/www /var/www COPY entrypoint.sh /entrypoint.sh COPY worker-entrypoint.sh /worker-entrypoint.sh COPY websockets-entrypoint.sh /websockets-entrypoint.sh +COPY schedule-entrypoint.sh /schedule-entrypoint.sh COPY wait-for-db.php /wait-for-db.php COPY --from=builder /usr/local/lib/php/extensions/no-debug-non-zts-20210902 /usr/local/lib/php/extensions/no-debug-non-zts-20210902 COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d diff --git a/Containerfile.fpm b/Containerfile.fpm index 0ba160b..7c3bd59 100644 --- a/Containerfile.fpm +++ b/Containerfile.fpm @@ -47,6 +47,7 @@ ARG DATE COPY --from=builder /var/www /var/www COPY entrypoint.fpm.sh /entrypoint.sh COPY worker-entrypoint.sh /worker-entrypoint.sh +COPY schedule-entrypoint.sh /schedule-entrypoint.sh COPY websockets-entrypoint.sh /websockets-entrypoint.sh COPY wait-for-db.php /wait-for-db.php COPY --from=builder /usr/local/lib/php/extensions/no-debug-non-zts-20210902 /usr/local/lib/php/extensions/no-debug-non-zts-20210902 diff --git a/schedule-entrypoint.sh b/schedule-entrypoint.sh new file mode 100755 index 0000000..c6685aa --- /dev/null +++ b/schedule-entrypoint.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -xeo pipefail + +php /wait-for-db.php + +if [[ ! -e storage/.docker.init ]]; +then + echo "Database is not initialized yet, exiting..." + sleep 5 + exit 1 +fi + +gosu www-data php artisan migrate:status | grep No && migrations=yes || migrations=no +if [ $migrations = "yes" ]; +then + echo "Database needs migrations, exiting..." + sleep 5 + exit 1 +fi + +gosu www-data php artisan schedule:work