Improved docker-entrypoint_*.sh scripts.

This commit is contained in:
Leonid Nikitin 2024-06-11 23:43:37 +05:00
parent 6998424b78
commit 74f7b88bce
Signed by: kor-elf
GPG Key ID: 3C0F720C170F6E1D
2 changed files with 10 additions and 6 deletions

View File

@ -5,6 +5,7 @@ set -euo pipefail
WAITLOOPS=5 WAITLOOPS=5
SLEEPSEC=1 SLEEPSEC=1
unitd="unitd" unitd="unitd"
role=${CONTAINER_ROLE:-app}
curl_put() curl_put()
{ {
@ -22,7 +23,7 @@ curl_put()
return 0 return 0
} }
if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then if [ "$role" = "app" ]; then
echo "$0: Launching Unit daemon to perform initial configuration..." echo "$0: Launching Unit daemon to perform initial configuration..."
/usr/sbin/$unitd --control unix:/var/run/control.unit.sock /usr/sbin/$unitd --control unix:/var/run/control.unit.sock
for i in $(/usr/bin/seq $WAITLOOPS); do for i in $(/usr/bin/seq $WAITLOOPS); do
@ -61,7 +62,7 @@ if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then
if [ ! -z ${UNIT_SOURCE+x} ] if [ ! -z ${UNIT_SOURCE+x} ]
then 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" curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source"
fi fi

View File

@ -5,6 +5,7 @@ set -euo pipefail
WAITLOOPS=5 WAITLOOPS=5
SLEEPSEC=1 SLEEPSEC=1
unitd="unitd" unitd="unitd"
role=${CONTAINER_ROLE:-app}
curl_put() curl_put()
{ {
@ -22,7 +23,7 @@ curl_put()
return 0 return 0
} }
if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then if [ "$role" = "app" ]; then
echo "$0: Launching Unit daemon to perform initial configuration..." echo "$0: Launching Unit daemon to perform initial configuration..."
/usr/sbin/$unitd --control unix:/var/run/control.unit.sock /usr/sbin/$unitd --control unix:/var/run/control.unit.sock
for i in $(/usr/bin/seq $WAITLOOPS); do for i in $(/usr/bin/seq $WAITLOOPS); do
@ -61,7 +62,7 @@ if [ "$unitd" = "unitd" ] || [ "$unitd" = "unitd-debug" ]; then
if [ ! -z ${UNIT_SOURCE+x} ] if [ ! -z ${UNIT_SOURCE+x} ]
then 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" curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source"
fi fi
@ -102,8 +103,10 @@ php artisan config:cache
php artisan event:cache php artisan event:cache
php artisan route:cache php artisan route:cache
php artisan view: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 unit:unit /var/www/html
chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache 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 chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache