diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bcdff8d2..d26db2ec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,14 +18,13 @@ The below example shows creating a `v2.2.1` release. ``` git checkout master git checkout -b rel-2.2.1 -sed -i s/master/v2.2.1/g Dockerfile +Set `ENV cachetversion=v2.2.1` in Dockerfile git commit -am "Cachet v2.2.1 release" git tag -a v2.2.1 -m "Cachet Release v2.2.1" git push origin v2.2.1 ``` -Then to finish the process: +Then to finish the process: * Add [Release on GitHub](https://github.com/CachetHQ/Docker/releases) * Add automated build for the new tag on [Docker Hub](https://hub.docker.com/r/cachethq/docker/builds/) - diff --git a/Dockerfile b/Dockerfile index 7996367f..1572a71c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,9 @@ FROM debian:jessie MAINTAINER Alt Three +ARG cachet_ver +ENV cachet_ver master + # Using debian packages instead of compiling from scratch RUN DEBIAN_FRONTEND=noninteractive \ echo "APT::Install-Recommends \"0\";" >> /etc/apt/apt.conf.d/02recommends && \ @@ -9,35 +12,41 @@ RUN DEBIAN_FRONTEND=noninteractive \ apt-get clean && \ apt-get -q -y update && \ apt-get -q -y install \ - ca-certificates php5-fpm=5.* php5-curl php5-readline php5-mcrypt \ + ca-certificates php5-fpm=5.* php5-curl php5-readline php5-mcrypt sudo \ php5-mysql php5-apcu php5-cli php5-gd php5-mysql php5-pgsql php5-sqlite \ wget sqlite git libsqlite3-dev postgresql-client mysql-client curl supervisor cron unzip && \ apt-get clean && apt-get autoremove -q && \ rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* -COPY docker/supervisord.conf /etc/supervisor/supervisord.conf COPY docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf +COPY docker/supervisord.conf /etc/supervisor/supervisord.conf RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf +RUN mkdir -p /var/www/html && \ + chown -R www-data /var/www + +COPY docker/crontab /etc/cron.d/artisan-schedule +COPY docker/entrypoint.sh /sbin/entrypoint.sh + +RUN chmod 0644 /etc/cron.d/artisan-schedule && \ + touch /var/log/cron.log + +RUN adduser www-data sudo && \ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers WORKDIR /var/www/html/ +USER www-data # Install composer RUN curl -sS https://getcomposer.org/installer | php -RUN wget https://github.com/cachethq/Cachet/archive/master.tar.gz && \ - tar xzvf master.tar.gz --strip-components=1 && \ +RUN wget https://github.com/cachethq/Cachet/archive/${cachet_ver}.tar.gz && \ + tar xzvf ${cachet_ver}.tar.gz --strip-components=1 && \ chown -R www-data /var/www/html && \ - rm -r master.tar.gz && \ + rm -r ${cachet_ver}.tar.gz && \ php composer.phar install --no-dev -o -COPY docker/entrypoint.sh /sbin/entrypoint.sh COPY docker/.env.docker /var/www/html/.env -COPY docker/crontab /etc/cron.d/artisan-schedule - -RUN chmod 0644 /etc/cron.d/artisan-schedule &&\ - touch /var/log/cron.log &&\ - chown www-data /var/www/html/.env VOLUME /var/www EXPOSE 8000 diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 02028a2e..c8d7f78c 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -34,11 +34,12 @@ initialize_system() { APP_URL=${APP_URL:-http://localhost} APP_KEY=${APP_KEY:-SECRET} - DB_DRIVER=${DB_DRIVER:-mysql} - DB_HOST=${DB_HOST:-mysql} + DB_DRIVER=${DB_DRIVER:-pgsql} + DB_HOST=${DB_HOST:-postgres} DB_DATABASE=${DB_DATABASE:-cachet} - DB_USERNAME=${DB_USERNAME:-cachet} - DB_PASSWORD=${DB_PASSWORD:-cachet} + DB_USERNAME=${DB_USERNAME:-postgres} + DB_PASSWORD=${DB_PASSWORD:-postgres} + DB_PORT=${DB_PORT:-5432} CACHE_DRIVER=${CACHE_DRIVER:-apc} SESSION_DRIVER=${SESSION_DRIVER:-apc} @@ -88,15 +89,15 @@ initialize_system() { php composer.phar install --no-dev -o php artisan app:install rm -rf bootstrap/cache/* - touch /.cachet-installed + touch /var/www/.cachet-installed start_system } start_system() { check_database_connection - [ -f "/.cachet-installed" ] && echo "Starting Cachet" || initialize_system + [ -f "/var/www/.cachet-installed" ] && echo "Starting Cachet" || initialize_system php artisan config:cache - exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf + sudo /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf } case ${1} in diff --git a/docker/php-fpm-pool.conf b/docker/php-fpm-pool.conf index b5cff736..9d773222 100644 --- a/docker/php-fpm-pool.conf +++ b/docker/php-fpm-pool.conf @@ -6,11 +6,10 @@ listen = 9000 request_terminate_timeout = 120s -pm = dynamic +pm = ondemand pm.max_children = 5 -pm.start_servers = 2 -pm.min_spare_servers = 1 -pm.max_spare_servers = 3 +pm.process_idle_timeout = 10s +pm.max_requests = 500 chdir = / env[DB_DRIVER] = $DB_DRIVER diff --git a/docker/supervisord.conf b/docker/supervisord.conf index b3cd2054..45d547fd 100644 --- a/docker/supervisord.conf +++ b/docker/supervisord.conf @@ -1,6 +1,3 @@ -[unix_http_server] -file=/var/run/supervisor.sock ; (the path to the socket file) - [supervisord] logfile=/dev/null ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=0 ; (max main logfile bytes b4 rotation;default 50MB)