diff --git a/debian/Dockerfile b/debian/Dockerfile index 4dce691..e4595bd 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -82,7 +82,7 @@ COPY --from=prepare-app /tmp/public /tmp/public COPY --chmod=0755 scripts/init.sh /usr/local/bin/init.sh # Health check -HEALTHCHECK --start-period=10s \ +HEALTHCHECK --start-period=100s \ CMD REMOTE_ADDR=127.0.0.1 REQUEST_URI=/health REQUEST_METHOD=GET SCRIPT_FILENAME=/var/www/html/public/index.php cgi-fcgi -bind -connect 127.0.0.1:9000 | grep '{"status":"ok","message":"API is healthy"}' ENTRYPOINT ["/usr/local/bin/init.sh"] diff --git a/debian/docker-compose.yml b/debian/docker-compose.yml index ce9ad7d..ec2429f 100644 --- a/debian/docker-compose.yml +++ b/debian/docker-compose.yml @@ -40,7 +40,8 @@ services: networks: - app-network depends_on: - - app + app: + condition: service_healthy logging: *default-logging mysql: diff --git a/debian/scripts/init.sh b/debian/scripts/init.sh index 1f688e2..79824de 100755 --- a/debian/scripts/init.sh +++ b/debian/scripts/init.sh @@ -41,24 +41,26 @@ if [ "$*" = 'supervisord -c /etc/supervisor/supervisord.conf' ]; then # Clear and cache config in production if [ "$APP_ENV" = "production" ]; then - runuser -u www-data -- php artisan optimize runuser -u www-data -- php artisan package:discover - runuser -u www-data -- php artisan migrate --force + runuser -u www-data -- php artisan migrate --force + runuser -u www-data -- php artisan cache:clear # Clear after the migration + runuser -u www-data -- php artisan ninja:design-update + runuser -u www-data -- php artisan optimize # If first IN run, it needs to be initialized - if [ "$(php -d opcache.preload='' artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')" = "1" ]; then + if [ "$(runuser -u www-data -- php artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')" = "1" ]; then echo "Running initialization..." - - php artisan db:seed --force + + runuser -u www-data -- php artisan db:seed --force if [ -n "${IN_USER_EMAIL}" ] && [ -n "${IN_PASSWORD}" ]; then - php artisan ninja:create-account --email "${IN_USER_EMAIL}" --password "${IN_PASSWORD}" + runuser -u www-data -- php artisan ninja:create-account --email "${IN_USER_EMAIL}" --password "${IN_PASSWORD}" else echo "Initialization failed - Set IN_USER_EMAIL and IN_PASSWORD in .env" exit 1 fi - fi + fi echo "Production setup completed" fi diff --git a/docker/app/public/.keep b/docker/app/public/.keep deleted file mode 100644 index 8b13789..0000000 --- a/docker/app/public/.keep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docker/app/storage/.keep b/docker/app/storage/.keep deleted file mode 100644 index 8b13789..0000000 --- a/docker/app/storage/.keep +++ /dev/null @@ -1 +0,0 @@ -