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

View File

@ -35,6 +35,6 @@ RUN apt-get update && apt-get install -y openssh-server libpq5 libpq-dev unzip g
RUN pecl install -o -f igbinary && pecl install -o -f redis && docker-php-ext-enable redis igbinary && rm -rf /tmp/* RUN pecl install -o -f igbinary && pecl install -o -f redis && docker-php-ext-enable redis igbinary && rm -rf /tmp/*
COPY init /sbin/ COPY init /sbin/
RUN chmod 550 /sbin/init && chown 0:33 /sbin/init RUN chmod 550 /sbin/init && chown 0:0 /sbin/init
ENTRYPOINT [ "/sbin/init" ] ENTRYPOINT [ "/sbin/init" ]
CMD [ "php-fpm" ] CMD [ "php-fpm" ]

14
init
View File

@ -19,6 +19,8 @@ if [ "${role}" = "app" -a -e artisan ]; then
exec /bin/bash exec /bin/bash
fi fi
# Only adjust perms if this is an external mountpoint
if mountpoint -q ${php}; then
if [ "${env}" != "dev" -a -z "${SKIP_PERM}" ]; then if [ "${env}" != "dev" -a -z "${SKIP_PERM}" ]; then
echo "* Setting Permissions..." echo "* Setting Permissions..."
# Make sure our permissions are appropraite # Make sure our permissions are appropraite
@ -30,20 +32,24 @@ if [ "${role}" = "app" -a -e artisan ]; then
chown -R www-data:www-data ${php}/storage ${php}/bootstrap ${php}/composer.* chown -R www-data:www-data ${php}/storage ${php}/bootstrap ${php}/composer.*
[ -e ${php}/vendor ] && chown -R www-data:www-data ${php}/vendor [ -e ${php}/vendor ] && chown -R www-data:www-data ${php}/vendor
fi fi
fi
if [ "${env}" != "local" -a -r "artisan" ]; then if [ "${env}" != "local" -a -r "artisan" ]; then
# See if we need to refresh our dependancies # 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 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 if [ "${env}" != "dev" ]; then
NODEV="--no-dev" NODEV="--no-dev"
fi fi
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} [ "${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 ) 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 fi
if [ -r .migrate ]; then if [ -r .migrate ]; then