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