Added gettext, testing for artisan and enabled migrate before starting

This commit is contained in:
Deon George 2019-05-03 12:09:47 +10:00
parent 2976938437
commit 2a35efec11
2 changed files with 13 additions and 10 deletions

View File

@ -3,7 +3,8 @@
FROM php:7.2-fpm FROM php:7.2-fpm
RUN apt-get update && apt-get install -y openssh-server ssmtp libpq-dev unzip git libssl1.0-dev libldap-dev && rm -rf /var/lib/apt/lists/* /tmp/* \ RUN apt-get update && apt-get install -y openssh-server ssmtp libpq-dev unzip git libssl1.0-dev libldap-dev gettext \
&& rm -rf /var/lib/apt/lists/* /tmp/* \
&& useradd -c "Hosting Admin User" -u 1000 -g users -G www-data -d /var/www/html -M lamp \ && useradd -c "Hosting Admin User" -u 1000 -g users -G www-data -d /var/www/html -M lamp \
&& sed -i -e 's/^mailhub=mail$/mailhub=smtp/' -e "s/^hostname=/#hostname=/" -e 's/#FromLineOverride=YES/FromLineOverride=YES/' /etc/ssmtp/ssmtp.conf && sed -i -e 's/^mailhub=mail$/mailhub=smtp/' -e "s/^hostname=/#hostname=/" -e 's/#FromLineOverride=YES/FromLineOverride=YES/' /etc/ssmtp/ssmtp.conf
@ -12,9 +13,9 @@ RUN (cd / && patch -p0 ) < /tmp/sshd_config.patch && rm /tmp/sshd_config.patch
EXPOSE 9000/tcp 22/tcp EXPOSE 9000/tcp 22/tcp
RUN docker-php-ext-install -j$(nproc) pdo_mysql pdo_pgsql ldap RUN docker-php-ext-install -j$(nproc) pdo_mysql pdo_pgsql ldap gettext
RUN curl https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer RUN curl https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer
COPY start /usr/local/sbin COPY init /sbin
ENTRYPOINT [ "/usr/local/sbin/start" ] ENTRYPOINT [ "/sbin/init" ]
CMD [ "php-fpm" ] CMD [ "php-fpm" ]

View File

@ -2,7 +2,7 @@
set -e set -e
role=${CONTAINER_ROLE:-app} role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production} env=${APP_ENV:-live}
# General Setup # General Setup
if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then
@ -11,27 +11,29 @@ if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then
fi fi
# Laravel Specific # Laravel Specific
if [ "${role}" = "app" ]; then if [ "${role}" = "app" -a -e artisan ]; then
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.lock && ( -e .composer.refresh || ! -d vendor ) ]]; then
su www-data -s /bin/sh -c "composer install" && ( test -e .composer.refresh && rm -f .composer.refresh ) su www-data -s /bin/sh -c "composer install" && ( test -e .composer.refresh && rm -f .composer.refresh )
fi fi
echo "Running migration..."
(php artisan migrate)
echo "Caching configuration..." echo "Caching configuration..."
(php artisan config:cache && php artisan route:cache && php artisan view:cache) (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 "$@"
elif [ "$role" = "queue" ]; then elif [ "$role" = "queue" -a -e artisan ]; then
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
php ${PHP_OPTIONS} artisan queue:work --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} ${WORK_QUEUES:+--queue=${WORK_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} php ${PHP_OPTIONS} artisan queue:work --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} ${WORK_QUEUES:+--queue=${WORK_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}}
elif [ "$role" = "scheduler" ]; then elif [ "$role" = "scheduler" -a -e artisan ]; then
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
@ -43,6 +45,6 @@ elif [ "$role" = "scheduler" ]; then
done done
else else
echo "Could not match the container role \"${role}\"" echo "NO container role \"${role}\", AND/OR no laravel install, just starting php-fpm"
exit 1 exec /usr/local/bin/docker-php-entrypoint "$@"
fi fi