Enabled multi-use container invocation with roles

This commit is contained in:
Deon George 2018-05-07 13:34:45 +10:00
parent 3df8ec4de2
commit b48c38cee1
2 changed files with 33 additions and 4 deletions

View File

@ -12,9 +12,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
RUN curl https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer
COPY start /usr/local/sbin COPY start /usr/local/sbin
ENTRYPOINT [ "/usr/local/sbin/start" ] ENTRYPOINT [ "/usr/local/sbin/start" ]
CMD [ "php-fpm" ] CMD [ "php-fpm" ]
RUN docker-php-ext-install -j$(nproc) pdo_mysql pdo_pgsql
RUN curl https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer

31
start
View File

@ -5,4 +5,33 @@ if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then
start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22 start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22
fi fi
exec /usr/local/bin/docker-php-entrypoint "$@" set -e
role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}
if [ "${env}" != "local" -a -r "artisan" ]; then
echo "Caching configuration..."
(cd /var/www/html && php artisan config:cache && php artisan route:cache && php artisan view:cache)
fi
if [ "${role}" = "app" ]; then
exec /usr/local/bin/docker-php-entrypoint "$@"
elif [ "$role" = "queue" ]; then
echo "Running the queue..."
php /var/www/html/artisan queue:work --verbose --tries=3 --timeout=90
elif [ "$role" = "scheduler" ]; then
while [ true ]; do
php /var/www/html/artisan schedule:run --verbose --no-interaction &
sleep 60
done
else
echo "Could not match the container role \"${role}\""
exit 1
fi