Cache config in role containers if container contains the app and change mountpoint detection routine

This commit is contained in:
Deon George 2020-01-29 15:37:53 +11:00
parent f8bda40162
commit 5943f0df5a

34
init
View File

@ -6,6 +6,14 @@ env=${APP_ENV:-live}
php=${PHP_DIR:-/var/www/html}
composer=${COMPOSER_DIR:-/var/www/.composer}
function mp() {
set +e
mountpoint -q $1
local mp=$?
set -e
return ${mp}
}
# General Setup
if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then
[ ! -d /var/run/sshd ] && mkdir /var/run/sshd
@ -19,10 +27,8 @@ if [ "${role}" = "app" -a -e artisan ]; then
exec /bin/bash
fi
set +e
mountpoint -q ${php}
mp ${php}
mp=$?
set -e
# Only adjust perms if this is an external mountpoint
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
@ -47,10 +53,8 @@ if [ "${role}" = "app" -a -e artisan ]; then
NODEV="--no-dev"
fi
set +e
mountpoint -q ${composer}
mp ${php}
mp=$?
set -e
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
[ -n "${FORCE_PERMS}" -o "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chown -R www-data:www-data ${composer}
@ -62,13 +66,13 @@ if [ "${role}" = "app" -a -e artisan ]; then
[ -n "${FORCE_PERMS}" -o "${env}" != "dev" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
fi
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan config:cache && php artisan route:cache && php artisan view:cache)"
if [ -r .migrate ]; then
echo "* Running migration..."
su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate
fi
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan config:cache && php artisan route:cache && php artisan view:cache)"
fi
exec /usr/local/bin/docker-php-entrypoint "$@"
@ -79,6 +83,12 @@ elif [ "$role" = "queue" -a -e artisan ]; then
exec /bin/bash
fi
# We only check for non mount points, in case this container has the app inside
if ! mp ${php}; then
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan config:cache && php artisan route:cache && php artisan view:cache)"
fi
echo "* Running the queue..."
# We'll delay starting in case the app is caching
sleep 15
@ -95,6 +105,12 @@ elif [ "$role" = "scheduler" -a -e artisan ]; then
exec /bin/bash
fi
# We only check for non mount points, in case this container has the app inside
if ! mp ${php}; then
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan config:cache && php artisan route:cache && php artisan view:cache)"
fi
echo "* Running the scheduler..."
# We'll delay starting in case the app is caching
sleep 15