From ed4b1b033abe28d119ab63633ee72b7c5cdef978 Mon Sep 17 00:00:00 2001 From: jsw Date: Fri, 14 Aug 2015 10:29:33 +0800 Subject: [PATCH 1/7] stripped image down for base-image use --- Dockerfile | 25 +++++++++-------- README.md | 10 ++----- docker-compose.yml | 18 ------------ docker/.env.docker | 27 ------------------ docker/crontab | 2 -- docker/entrypoint.sh | 66 -------------------------------------------- 6 files changed, 16 insertions(+), 132 deletions(-) delete mode 100644 docker-compose.yml delete mode 100644 docker/.env.docker delete mode 100644 docker/crontab delete mode 100755 docker/entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 53c7fc0b..e1cc0f26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM debian:jessie -# Using nodesource and debian jessie packages instead of compiling from scratch +# Using debian jessie packages instead of compiling from scratch RUN DEBIAN_FRONTEND=noninteractive \ echo "APT::Install-Recommends \"0\";" >> /etc/apt/apt.conf.d/02recommends && \ echo "APT::Install-Suggests \"0\";" >> /etc/apt/apt.conf.d/02recommends && \ @@ -12,10 +12,7 @@ RUN DEBIAN_FRONTEND=noninteractive \ rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* COPY docker/supervisord.conf /etc/supervisor/supervisord.conf -COPY docker/entrypoint.sh /sbin/entrypoint.sh -RUN cd /var/www/html ;\ - wget https://github.com/cachethq/Cachet/archive/v1.1.1.tar.gz ;\ - tar xzvf v1.1.1.tar.gz --strip-components=1 +# COPY docker/entrypoint.sh /sbin/entrypoint.sh WORKDIR /var/www/html/ # copy the various nginx and supervisor conf (to handle both fpm and nginx) @@ -25,15 +22,19 @@ RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.co rm -f /etc/nginx/sites-enabled/* ;\ rm -f /etc/nginx/conf.d/* ;\ mv /var/www/html/docker/nginx-site.conf /etc/nginx/conf.d/default.conf ;\ - mv /var/www/html/docker/.env.docker /var/www/html/.env ;\ +# mv /var/www/html/docker/.env.docker /var/www/html/.env ;\ +# ^ Move this to upper level of image rm -r /var/www/html/docker ;\ chown -R www-data /var/www/html ;\ - curl -sS https://getcomposer.org/installer | php && php composer.phar install --no-dev -o + curl -sS https://getcomposer.org/installer | php -EXPOSE 8000 +# EXPOSE 8000 -COPY docker/crontab /etc/cron.d/artisan-schedule -RUN chmod 0644 /etc/cron.d/artisan-schedule -RUN touch /var/log/cron.log +# COPY docker/crontab /etc/cron.d/artisan-schedule +# RUN chmod 0644 /etc/cron.d/artisan-schedule +# RUN touch /var/log/cron.log -CMD ["/sbin/entrypoint.sh"] +# ^ Also these + +CMD ["/bin/bash"] +# ^ From debian:latest, had better not run it directly \ No newline at end of file diff --git a/README.md b/README.md index 70d15015..ba747600 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ -Cachet-Docker +# Cachet-Docker-Base -Run Cachet in a Docker container. - -# docker-compose -```bash -docker-compose up -``` +Base Image for cachethq/Docker +Contains configured Debian, PHP and NGINX environment diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 908842e2..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,18 +0,0 @@ -mysql: - image: mysql:5.6 - environment: - - MYSQL_ROOT_PASSWORD=cachet - - MYSQL_DATABASE=cachet - - MYSQL_USER=cachet - - MYSQL_PASSWORD=cachet -cachet: - build: . - ports: - - 80:8000 - links: - - mysql:mysql - environment: - - DB_HOST=mysql - - DB_DATABASE=cachet - - DB_USERNAME=cachet - - DB_PASSWORD=cachet diff --git a/docker/.env.docker b/docker/.env.docker deleted file mode 100644 index fed757fa..00000000 --- a/docker/.env.docker +++ /dev/null @@ -1,27 +0,0 @@ -APP_ENV={{APP_ENV}} -APP_DEBUG={{APP_DEBUG}} -APP_URL={{APP_URL}} -APP_KEY={{APP_KEY}} - -DB_DRIVER={{DB_DRIVER}} -DB_HOST={{DB_HOST}} -DB_DATABASE={{DB_DATABASE}} -DB_USERNAME={{DB_USERNAME}} -DB_PASSWORD={{DB_PASSWORD}} - -CACHE_DRIVER={{CACHE_DRIVER}} -SESSION_DRIVER={{SESSION_DRIVER}} -QUEUE_DRIVER={{QUEUE_DRIVER}} - -MAIL_DRIVER={{MAIL_DRIVER}} -MAIL_HOST={{MAIL_HOST}} -MAIL_PORT={{MAIL_PORT}} -MAIL_USERNAME={{MAIL_USERNAME}} -MAIL_PASSWORD={{MAIL_PASSWORD}} -MAIL_ADDRESS={{MAIL_ADDRESS}} -MAIL_NAME={{MAIL_NAME}} - -REDIS_HOST={{REDIS_HOST}} -REDIS_DATABASE={{REDIS_DATABASE}} -REDIS_PORT={{REDIS_PORT}} - diff --git a/docker/crontab b/docker/crontab deleted file mode 100644 index 1b0fa150..00000000 --- a/docker/crontab +++ /dev/null @@ -1,2 +0,0 @@ -#minute hour mday month wday who command -* * * * * www-data php /var/www/html/artisan schedule:run 1>> /dev/null 2>&1 diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100755 index 7792f658..00000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -set -e - -APP_ENV=${APP_ENV:-local} -APP_DEBUG=${APP_DEBUG:-true} -APP_URL=${APP_URL:-http://localhost} -APP_KEY=${APP_KEY:-8NGdcb4sL46YL0LBKE5WIJaEbizHFr9R} - -DB_DRIVER=${DB_DRIVER:-mysql} -DB_HOST=${DB_HOST:-mysql} -DB_DATABASE=${DB_DATABASE:-cachet} -DB_USERNAME=${DB_USERNAME:-cachet} -DB_PASSWORD=${DB_PASSWORD:-cachet} - -CACHE_DRIVER=${CACHE_DRIVER:-file} -SESSION_DRIVER=${SESSION_DRIVER:-file} -QUEUE_DRIVER=${QUEUE_DRIVER:-database} - -MAIL_DRIVER=${MAIL_DRIVER:-smtp} -MAIL_HOST=${MAIL_HOST:-mailtrap.io} -MAIL_PORT=${MAIL_PORT:-2525} -MAIL_USERNAME=${MAIL_USERNAME:-null} -MAIL_PASSWORD=${MAIL_PASSWORD:-null} -MAIL_ADDRESS=${MAIL_ADDRESS:-null} -MAIL_NAME=${MAIL_NAME:-null} - -REDIS_HOST=${REDIS_HOST:-null} -REDIS_DATABASE=${REDIS_DATABASE:-null} -REDIS_PORT=${REDIS_PORT:-null} - -# configure env file - -sed 's,{{APP_ENV}},'"${APP_ENV}"',g' -i /var/www/html/.env -sed 's,{{APP_DEBUG}},'"${APP_DEBUG}"',g' -i /var/www/html/.env -sed 's,{{APP_URL}},'"${APP_URL}"',g' -i /var/www/html/.env -sed 's,{{APP_KEY}},'"${APP_KEY}"',g' -i /var/www/html/.env - -sed 's,{{DB_DRIVER}},'"${DB_DRIVER}"',g' -i /var/www/html/.env -sed 's,{{DB_HOST}},'"${DB_HOST}"',g' -i /var/www/html/.env -sed 's,{{DB_DATABASE}},'"${DB_DATABASE}"',g' -i /var/www/html/.env -sed 's,{{DB_USERNAME}},'"${DB_USERNAME}"',g' -i /var/www/html/.env -sed 's,{{DB_PASSWORD}},'"${DB_PASSWORD}"',g' -i /var/www/html/.env - -sed 's,{{CACHE_DRIVER}},'"${CACHE_DRIVER}"',g' -i /var/www/html/.env -sed 's,{{SESSION_DRIVER}},'"${SESSION_DRIVER}"',g' -i /var/www/html/.env -sed 's,{{QUEUE_DRIVER}},'"${QUEUE_DRIVER}"',g' -i /var/www/html/.env - -sed 's,{{MAIL_DRIVER}},'"${MAIL_DRIVER}"',g' -i /var/www/html/.env -sed 's,{{MAIL_HOST}},'"${MAIL_HOST}"',g' -i /var/www/html/.env -sed 's,{{MAIL_PORT}},'"${MAIL_PORT}"',g' -i /var/www/html/.env -sed 's,{{MAIL_USERNAME}},'"${MAIL_USERNAME}"',g' -i /var/www/html/.env -sed 's,{{MAIL_PASSWORD}},'"${MAIL_PASSWORD}"',g' -i /var/www/html/.env -sed 's,{{MAIL_ADDRESS}},'"${MAIL_ADDRESS}"',g' -i /var/www/html/.env -sed 's,{{MAIL_NAME}},'"${MAIL_NAME}"',g' -i /var/www/html/.env - -sed 's,{{REDIS_HOST}},'"${REDIS_HOST}"',g' -i /var/www/html/.env -sed 's,{{REDIS_DATABASE}},'"${REDIS_DATABASE}"',g' -i /var/www/html/.env -sed 's,{{REDIS_PORT}},'"${REDIS_PORT}"',g' -i /var/www/html/.env - -#Clear cache -/usr/bin/php composer.phar install --no-dev -o - -echo "Starting supervisord..." -exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf - -exit 0 From 9f93b3aa4248594fa0afa939fdce8e68be847581 Mon Sep 17 00:00:00 2001 From: jsw Date: Fri, 14 Aug 2015 11:02:26 +0800 Subject: [PATCH 2/7] Fix problems (+2 squashed commit) Squashed commit: [88f10b1] Output some logs is really helpful [aeda981] fix copy issue --- Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index e1cc0f26..3ce4992e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,27 +4,26 @@ FROM debian:jessie RUN DEBIAN_FRONTEND=noninteractive \ echo "APT::Install-Recommends \"0\";" >> /etc/apt/apt.conf.d/02recommends && \ echo "APT::Install-Suggests \"0\";" >> /etc/apt/apt.conf.d/02recommends && \ - apt-get -qq update && \ - apt-get -qq install \ + apt-get -q -y update && \ + apt-get -q -y install \ ca-certificates nginx php5-fpm=5.* php5-curl php5-readline php5-mcrypt php5-mysql php5-apcu php5-cli \ wget sqlite libsqlite3-dev curl supervisor cron php5-pgsql && \ apt-get clean && apt-get autoremove -qq && \ rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* -COPY docker/supervisord.conf /etc/supervisor/supervisord.conf +ADD docker/supervisord.conf /etc/supervisor/supervisord.conf +ADD docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf +ADD docker/nginx-site.conf /etc/nginx/conf.d/default.conf # COPY docker/entrypoint.sh /sbin/entrypoint.sh WORKDIR /var/www/html/ # copy the various nginx and supervisor conf (to handle both fpm and nginx) RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf ;\ echo "daemon off;" >> /etc/nginx/nginx.conf ;\ - mv /var/www/html/docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf ;\ rm -f /etc/nginx/sites-enabled/* ;\ rm -f /etc/nginx/conf.d/* ;\ - mv /var/www/html/docker/nginx-site.conf /etc/nginx/conf.d/default.conf ;\ # mv /var/www/html/docker/.env.docker /var/www/html/.env ;\ # ^ Move this to upper level of image - rm -r /var/www/html/docker ;\ chown -R www-data /var/www/html ;\ curl -sS https://getcomposer.org/installer | php @@ -37,4 +36,4 @@ RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.co # ^ Also these CMD ["/bin/bash"] -# ^ From debian:latest, had better not run it directly \ No newline at end of file +# ^ From debian:latest, had better not run it directly From 7049fc8f3ffb86e4d3aa276b3dcf51cc0139df9f Mon Sep 17 00:00:00 2001 From: jsw Date: Fri, 14 Aug 2015 19:00:30 +0800 Subject: [PATCH 3/7] Yup, we need git here for composer. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ce4992e..a7c2c91e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,8 @@ RUN DEBIAN_FRONTEND=noninteractive \ apt-get -q -y update && \ apt-get -q -y install \ ca-certificates nginx php5-fpm=5.* php5-curl php5-readline php5-mcrypt php5-mysql php5-apcu php5-cli \ - wget sqlite libsqlite3-dev curl supervisor cron php5-pgsql && \ - apt-get clean && apt-get autoremove -qq && \ + wget sqlite git libsqlite3-dev curl supervisor cron php5-pgsql && \ + apt-get clean && apt-get autoremove -q && \ rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* ADD docker/supervisord.conf /etc/supervisor/supervisord.conf From 2e89c2e3d8f21e551e1b50a83360835aafcbb99c Mon Sep 17 00:00:00 2001 From: jsw Date: Sat, 15 Aug 2015 08:46:52 +0800 Subject: [PATCH 4/7] prefer COPY over ADD --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a7c2c91e..030f7564 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,9 @@ RUN DEBIAN_FRONTEND=noninteractive \ apt-get clean && apt-get autoremove -q && \ rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* -ADD docker/supervisord.conf /etc/supervisor/supervisord.conf -ADD docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf -ADD docker/nginx-site.conf /etc/nginx/conf.d/default.conf +COPY docker/supervisord.conf /etc/supervisor/supervisord.conf +COPY docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf +COPY docker/nginx-site.conf /etc/nginx/conf.d/default.conf # COPY docker/entrypoint.sh /sbin/entrypoint.sh WORKDIR /var/www/html/ From 0d38f6b6a4777da058e8b7dcbf2fc6e2efbfa09c Mon Sep 17 00:00:00 2001 From: jsw Date: Sat, 15 Aug 2015 08:56:52 +0800 Subject: [PATCH 5/7] replace ;\ to && \ --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 030f7564..8bfe5763 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,13 +18,13 @@ COPY docker/nginx-site.conf /etc/nginx/conf.d/default.conf WORKDIR /var/www/html/ # copy the various nginx and supervisor conf (to handle both fpm and nginx) -RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf ;\ - echo "daemon off;" >> /etc/nginx/nginx.conf ;\ - rm -f /etc/nginx/sites-enabled/* ;\ - rm -f /etc/nginx/conf.d/* ;\ -# mv /var/www/html/docker/.env.docker /var/www/html/.env ;\ +RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf && \ + echo "daemon off;" >> /etc/nginx/nginx.conf && \ + rm -f /etc/nginx/sites-enabled/* && \ + rm -f /etc/nginx/conf.d/* && \ +# mv /var/www/html/docker/.env.docker /var/www/html/.env && \ # ^ Move this to upper level of image - chown -R www-data /var/www/html ;\ + chown -R www-data /var/www/html && \ curl -sS https://getcomposer.org/installer | php # EXPOSE 8000 From 1df846775f12e94dda1fa4c41f9b176d2e0fe976 Mon Sep 17 00:00:00 2001 From: jsw Date: Sat, 15 Aug 2015 09:34:48 +0800 Subject: [PATCH 6/7] COPY then rm...... OK my fault --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8bfe5763..1a24632f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN DEBIAN_FRONTEND=noninteractive \ COPY docker/supervisord.conf /etc/supervisor/supervisord.conf COPY docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf -COPY docker/nginx-site.conf /etc/nginx/conf.d/default.conf + # COPY docker/entrypoint.sh /sbin/entrypoint.sh WORKDIR /var/www/html/ @@ -27,6 +27,8 @@ RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.co chown -R www-data /var/www/html && \ curl -sS https://getcomposer.org/installer | php +COPY docker/nginx-site.conf /etc/nginx/conf.d/default.conf + # EXPOSE 8000 # COPY docker/crontab /etc/cron.d/artisan-schedule From d3506c1ad7af80933cb97bfa60c48a00ccb00f45 Mon Sep 17 00:00:00 2001 From: jsw Date: Sat, 15 Aug 2015 09:38:15 +0800 Subject: [PATCH 7/7] sqlite driver --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1a24632f..1d501366 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN DEBIAN_FRONTEND=noninteractive \ apt-get -q -y update && \ apt-get -q -y install \ ca-certificates nginx php5-fpm=5.* php5-curl php5-readline php5-mcrypt php5-mysql php5-apcu php5-cli \ - wget sqlite git libsqlite3-dev curl supervisor cron php5-pgsql && \ + wget sqlite git libsqlite3-dev curl supervisor cron php5-pgsql php5-sqlite && \ apt-get clean && apt-get autoremove -q && \ rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/*