Enhancements for containers with applications

This commit is contained in:
Deon George
2020-01-24 23:09:56 +11:00
parent cb2da835a3
commit 3bddae369e
2 changed files with 22 additions and 16 deletions

36
init
View File

@@ -19,31 +19,37 @@ if [ "${role}" = "app" -a -e artisan ]; then
exec /bin/bash
fi
if [ "${env}" != "dev" -a -z "${SKIP_PERM}" ]; then
echo "* Setting Permissions..."
# Make sure our permissions are appropraite
find ${php} -type f -exec chmod 640 {} \;
find ${php} -type d -exec chmod 750 {} \;
chmod o+rx ${php}
chmod -R o+rx ${php}/public
chown -R lamp:www-data ${php}
chown -R www-data:www-data ${php}/storage ${php}/bootstrap ${php}/composer.*
[ -e ${php}/vendor ] && chown -R www-data:www-data ${php}/vendor
# Only adjust perms if this is an external mountpoint
if mountpoint -q ${php}; then
if [ "${env}" != "dev" -a -z "${SKIP_PERM}" ]; then
echo "* Setting Permissions..."
# Make sure our permissions are appropraite
find ${php} -type f -exec chmod 640 {} \;
find ${php} -type d -exec chmod 750 {} \;
chmod o+rx ${php}
chmod -R o+rx ${php}/public
chown -R lamp:www-data ${php}
chown -R www-data:www-data ${php}/storage ${php}/bootstrap ${php}/composer.*
[ -e ${php}/vendor ] && chown -R www-data:www-data ${php}/vendor
fi
fi
if [ "${env}" != "local" -a -r "artisan" ]; then
# See if we need to refresh our dependancies
if [[ -r composer.lock && ( -e .composer.refresh || ! -d vendor ) ]]; then
if [[ -r composer.json && ( -e .composer.refresh || ! -d vendor ) ]]; then
rm -f ${php}/bootstrap/cache/*.php
[ "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chown -R www-data:www-data ${composer}
[ ! -d ${php}/vendor ] && mkdir -m 750 ${php}/vendor && chown www-data:www-data ${php}/vendor
if [ "${env}" != "dev" ]; then
NODEV="--no-dev"
fi
[ "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
if mountpoint -q ${composer}; then
[ "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chown -R www-data:www-data ${composer}
[ ! -d ${php}/vendor ] && mkdir -m 750 ${php}/vendor && chown www-data:www-data ${php}/vendor
[ "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
fi
su www-data -s /bin/sh -c "composer install --optimize-autoloader ${NODEV}" && ( test -e .composer.refresh && rm -f .composer.refresh )
[ "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chmod g-w ${php}
[ "${env}" != "dev" -a -z "${SKIP_PERM}" ] && mountpoint -q ${composer} && chmod g-w ${php}
fi
if [ -r .migrate ]; then