From 74f7b88bce5e49419f404cd67ff5109d2ac904bc Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Tue, 11 Jun 2024 23:43:37 +0500 Subject: [PATCH] Improved docker-entrypoint_*.sh scripts. --- app/docker/docker-entrypoint_dev.sh | 5 +++-- app/docker/docker-entrypoint_prod.sh | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/docker/docker-entrypoint_dev.sh b/app/docker/docker-entrypoint_dev.sh index a885fa2..c447b67 100644 --- a/app/docker/docker-entrypoint_dev.sh +++ b/app/docker/docker-entrypoint_dev.sh @@ -5,6 +5,7 @@ set -euo pipefail WAITLOOPS=5 SLEEPSEC=1 unitd="unitd" +role=${CONTAINER_ROLE:-app} curl_put() { @@ -22,7 +23,7 @@ curl_put() return 0 } -if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then +if [ "$role" = "app" ]; then echo "$0: Launching Unit daemon to perform initial configuration..." /usr/sbin/$unitd --control unix:/var/run/control.unit.sock for i in $(/usr/bin/seq $WAITLOOPS); do @@ -61,7 +62,7 @@ if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then if [ ! -z ${UNIT_SOURCE+x} ] then - echo "[${UNIT_SOURCE}]" > /docker-entrypoint.d/unit_source.json + echo $UNIT_SOURCE > /docker-entrypoint.d/unit_source.json curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source" fi diff --git a/app/docker/docker-entrypoint_prod.sh b/app/docker/docker-entrypoint_prod.sh index 0ea0a31..b066f56 100644 --- a/app/docker/docker-entrypoint_prod.sh +++ b/app/docker/docker-entrypoint_prod.sh @@ -5,6 +5,7 @@ set -euo pipefail WAITLOOPS=5 SLEEPSEC=1 unitd="unitd" +role=${CONTAINER_ROLE:-app} curl_put() { @@ -22,7 +23,7 @@ curl_put() return 0 } -if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then +if [ "$role" = "app" ]; then echo "$0: Launching Unit daemon to perform initial configuration..." /usr/sbin/$unitd --control unix:/var/run/control.unit.sock for i in $(/usr/bin/seq $WAITLOOPS); do @@ -61,7 +62,7 @@ if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then if [ ! -z ${UNIT_SOURCE+x} ] then - echo "[${UNIT_SOURCE}]" > /docker-entrypoint.d/unit_source.json + echo $UNIT_SOURCE > /docker-entrypoint.d/unit_source.json curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source" fi @@ -102,8 +103,10 @@ php artisan config:cache php artisan event:cache php artisan route:cache php artisan view:cache -php artisan migrate --force - +php artisan storage:link +if [ "$role" = "app" ]; then + php artisan migrate --force +fi chown -R unit:unit /var/www/html chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache