diff --git a/Dockerfile b/Dockerfile index 9935a3b..cfd946a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,10 @@ RUN apt-get update && apt-get install -y openssh-server libpq5 libpq-dev unzip g && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Enable phpredis -RUN pecl install -o -f igbinary && pecl install -o -f redis && docker-php-ext-enable redis igbinary && rm -rf /tmp/* +RUN apt-get update && apt-get install -y redis \ + && pecl install -o -f igbinary && pecl install -o -f redis && docker-php-ext-enable redis igbinary \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Enable phpmemcache RUN apt-get update && apt-get install -y memcached libmemcachedutil2 zlib1g-dev libmemcached-dev \ diff --git a/init b/init index c138e3b..230c319 100755 --- a/init +++ b/init @@ -6,12 +6,14 @@ env=${APP_ENV:-live} php=${PHP_DIR:-/var/www/html} composer=${COMPOSER_DIR:-/var/www/.composer} -NO_NGINX=${NO_NGINX:-TRUE} +NGINX_START=${NGINX_START:-TRUE} SSH_START=${SSH_START:-FALSE} +REDIS_START=${SSH_START:-FALSE} # To run a local queue, running jobs from the queue "hostname" LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE} -#LOCAL_QUEUES= Optional additional queues to run for +# Optional additional queues to run for +#LOCAL_QUEUES= function mp() { set +e @@ -23,18 +25,26 @@ function mp() { function nginx_start() { # Start NGINX - if [ -x /usr/sbin/nginx -a "${NO_NGINX}" != "TRUE" ]; then + if [ -x /usr/sbin/nginx -a "${NGINX_START}" == "TRUE" ]; then echo "* Starting NGINX..." start-stop-daemon --start --pidfile /var/run/nginx.pid --exec /usr/sbin/nginx -- -g 'daemon on; master_process on;' fi } # 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 start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22 fi +if [ -x /usr/bin/redis-server -a "${REDIS_START}" == "TRUE" ]; then + start-stop-daemon --start --quiet --oknodo --umask 007 --pidfile /var/run/redis-server.pid --chuid redis:redis --exec /usr/bin/redis-server -- /etc/redis/redis.conf +fi + +if [ -x /usr/bin/memcached -a "${REDIS_START}" == "TRUE" ]; then + start-stop-daemon --start --quiet --exec "/usr/share/memcached/scripts/start-memcached" -- /etc/memcached.conf /var/run/memcached.pid +fi + # Laravel Specific if [ "${role}" = "app" -a -e artisan ]; then if [ ! -e ${php}/.env ]; then @@ -62,6 +72,8 @@ if [ "${role}" = "app" -a -e artisan ]; then if [ "${env}" != "local" -a -r "artisan" ]; then # See if we need to refresh our dependancies if [[ -r composer.json && ( -e .composer.refresh || ! -d vendor ) ]]; then + echo "* Composer installing dependancies..." + rm -f ${php}/bootstrap/cache/*.php if [ "${env}" != "local" ]; then NODEV="--no-dev" @@ -110,8 +122,9 @@ if [ "${role}" = "app" -a -e artisan ]; then fi nginx_start + if [ "${LOCAL_QUEUE}" = "TRUE" ]; then - echo "* Starting local queue for [${LOCAL_QUEUES}]..." + echo "* Starting local queue for [$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}}] with job timeout of [${WORK_TIMEOUT:-90}], trying [${WORK_TRIES:-1}] times..." su www-data -s /bin/sh -c " (while true; do php ${PHP_OPTIONS} artisan queue:work --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} --queue=$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}; done) & "