From 7325415f1e8ee0ad11b38f10b2c14c6db85ae795 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 16:46:38 -0700 Subject: [PATCH 01/10] Attempt to launch as a regular user --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index ef975451..2cb2cb1d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -165,7 +165,7 @@ start_system() { check_configured echo "Starting Cachet! ..." php artisan config:cache - sudo /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf + /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf } start_system From b9569aa86e36a90ebb2be7a0f5677869c1246555 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 16:55:53 -0700 Subject: [PATCH 02/10] change pid path --- conf/php-fpm-pool.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/php-fpm-pool.conf b/conf/php-fpm-pool.conf index 8d389dc6..90c1cf18 100644 --- a/conf/php-fpm-pool.conf +++ b/conf/php-fpm-pool.conf @@ -2,6 +2,8 @@ user = www-data group = www-data +pid = /var/run/php5-fpm.pid + listen = 9000 request_terminate_timeout = 120s From 8304917366634abc6204fdd1d0ec9e585e9024b0 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 16:56:32 -0700 Subject: [PATCH 03/10] touch and chown php-fpm pid --- Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Dockerfile b/Dockerfile index 85ad726c..1d94c4a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,13 @@ RUN adduser www-data sudo && \ RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ ln -sf /dev/stderr /var/log/nginx/error.log +RUN touch /var/run/nginx.pid && \ + chown -R www-data:www-data /var/run/nginx.pid && \ + chown -R www-data:www-data /var/cache/nginx + +RUN touch /var/run/php5-fpm.pid && \ + chown -R www-data:www-data /var/run/php5-fpm.pid + WORKDIR /var/www/html/ USER www-data From 03e431c82b009637c3bb8ab944c0c77757fcd57e Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 17:02:45 -0700 Subject: [PATCH 04/10] expose port 8000 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1d94c4a1..6513f787 100644 --- a/Dockerfile +++ b/Dockerfile @@ -78,6 +78,6 @@ RUN wget https://github.com/cachethq/Cachet/archive/${cachet_ver}.tar.gz && \ COPY conf/.env.docker /var/www/html/.env COPY entrypoint.sh /sbin/entrypoint.sh -EXPOSE 80 +EXPOSE 8000 CMD ["/sbin/entrypoint.sh"] From 02ce4300f359aa287f72a2db2a37d377f7fd3123 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 17:03:09 -0700 Subject: [PATCH 05/10] port 8000 on nginx --- conf/nginx-site.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx-site.conf b/conf/nginx-site.conf index efdc509d..2cc04369 100644 --- a/conf/nginx-site.conf +++ b/conf/nginx-site.conf @@ -1,5 +1,5 @@ server { - listen 80 default; ## Listen for ipv4; this line is default and implied + listen 8000 default; ## Listen for ipv4; this line is default and implied # Make site accessible from http://localhost/ server_name localhost; From f3369d97bccdd4b1d44905caff6799e573fe5371 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 17:04:15 -0700 Subject: [PATCH 06/10] remove user specification php-fpm --- conf/php-fpm-pool.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/conf/php-fpm-pool.conf b/conf/php-fpm-pool.conf index 90c1cf18..4a994e98 100644 --- a/conf/php-fpm-pool.conf +++ b/conf/php-fpm-pool.conf @@ -1,7 +1,4 @@ [www] -user = www-data -group = www-data - pid = /var/run/php5-fpm.pid listen = 9000 From a83ae57d57478c8871e6d6afb216af4927150905 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 17:06:14 -0700 Subject: [PATCH 07/10] compose port 8000 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index c47aca43..6d37ffe0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: cachet: build: . ports: - - 80:80 + - 80:8000 links: - postgres:postgres environment: From 7dc5b92c99d9d6675f82f602a1e75944e347b395 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 17:12:55 -0700 Subject: [PATCH 08/10] pid is global --- conf/php-fpm-pool.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/php-fpm-pool.conf b/conf/php-fpm-pool.conf index 4a994e98..e9c2e9aa 100644 --- a/conf/php-fpm-pool.conf +++ b/conf/php-fpm-pool.conf @@ -1,6 +1,4 @@ [www] -pid = /var/run/php5-fpm.pid - listen = 9000 request_terminate_timeout = 120s @@ -24,3 +22,4 @@ access.log = /dev/stdout [global] daemonize = no error_log = /dev/stderr +pid = /var/run/php5-fpm.pid From e5f3e5a28d34f014a5a24db2997f958785322657 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 18:29:30 -0700 Subject: [PATCH 09/10] put composer in /bin --- Dockerfile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6513f787..22134095 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ENV cachet_ver ${cachet_ver:-master} ENV PG_MAJOR 9.5 ENV NGINX_VERSION 1.10.1-1~jessie -ENV COMPOSER_VERSION 1.2.1 +ENV COMPOSER_VERSION 1.4.1 RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 @@ -35,6 +35,13 @@ RUN DEBIAN_FRONTEND=noninteractive \ apt-get clean && apt-get autoremove -q && \ rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* +# Install composer +RUN php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" && \ + php -r "copy('https://composer.github.io/installer.sig', '/tmp/composer-setup.sig');" && \ + php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && \ + php /tmp/composer-setup.php --version=$COMPOSER_VERSION --install-dir=bin && \ + php -r "unlink('/tmp/composer-setup.php');" + COPY conf/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf COPY conf/supervisord.conf /etc/supervisor/supervisord.conf COPY conf/nginx-site.conf /etc/nginx/conf.d/default.conf @@ -43,9 +50,6 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf RUN mkdir -p /var/www/html && \ chown -R www-data /var/www -RUN adduser www-data sudo && \ - echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - # forward request and error logs to docker log collector RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ ln -sf /dev/stderr /var/log/nginx/error.log @@ -53,26 +57,22 @@ RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ RUN touch /var/run/nginx.pid && \ chown -R www-data:www-data /var/run/nginx.pid && \ chown -R www-data:www-data /var/cache/nginx - + RUN touch /var/run/php5-fpm.pid && \ chown -R www-data:www-data /var/run/php5-fpm.pid +RUN adduser www-data sudo && \ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + WORKDIR /var/www/html/ USER www-data -# Install composer -RUN php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" && \ - php -r "copy('https://composer.github.io/installer.sig', '/tmp/composer-setup.sig');" && \ - php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && \ - php /tmp/composer-setup.php --version=$COMPOSER_VERSION && \ - php -r "unlink('/tmp/composer-setup.php');" && \ - php composer.phar global require "hirak/prestissimo:^0.3" - 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 ${cachet_ver}.tar.gz && \ - php composer.phar install --no-dev -o && \ + php /bin/composer.phar global require "hirak/prestissimo:^0.3" && \ + php /bin/composer.phar install --no-dev -o && \ rm -rf bootstrap/cache/* COPY conf/.env.docker /var/www/html/.env From 13f66242830e77dbe3123e722a75ba12ed163ce6 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Mar 2017 18:50:22 -0700 Subject: [PATCH 10/10] switch to port 8000 --- openshift/cachethd-dc.yaml | 2 +- test/docker-compose-mysql.yml | 2 +- test/test.full.bats | 10 +++++----- test/test.mysql.bats | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openshift/cachethd-dc.yaml b/openshift/cachethd-dc.yaml index f4fc507f..259af1b4 100644 --- a/openshift/cachethd-dc.yaml +++ b/openshift/cachethd-dc.yaml @@ -132,4 +132,4 @@ spec: dnsPolicy: ClusterFirst securityContext: runAsUser: 0 -status: \ No newline at end of file +status: diff --git a/test/docker-compose-mysql.yml b/test/docker-compose-mysql.yml index 9a10b8bf..8bb3053d 100644 --- a/test/docker-compose-mysql.yml +++ b/test/docker-compose-mysql.yml @@ -11,7 +11,7 @@ services: cachet: image: docker_cachet ports: - - 80:80 + - 80:8000 links: - mysql:mysql environment: diff --git a/test/test.full.bats b/test/test.full.bats index ab373c3a..bd8c6f31 100755 --- a/test/test.full.bats +++ b/test/test.full.bats @@ -54,17 +54,17 @@ load "lib/output" } @test "[$TEST_FILE] curl 200 response test" { - run curl_container docker_cachet_1 /auth/login --head + run curl_container docker_cachet_1 :8000/auth/login --head assert_output -l 0 $'HTTP/1.1 200 OK\r' } @test "[$TEST_FILE] login test" { - run curl_container docker_cachet_1 /auth/login --head --user test:test123 + run curl_container docker_cachet_1 :8000/auth/login --head --user test:test123 assert_output -l 0 $'HTTP/1.1 200 OK\r' } @test "[$TEST_FILE] check for curl API pong" { - run curl_container docker_cachet_1 /api/v1/ping + run curl_container docker_cachet_1 :8000/api/v1/ping assert_output -l 0 $'{"data":"Pong!"}' } @@ -86,12 +86,12 @@ load "lib/output" } @test "[$TEST_FILE] post-restart API pong" { - run curl_container docker_cachet_1 /api/v1/ping + run curl_container docker_cachet_1 :8000/api/v1/ping assert_output -l 0 $'{"data":"Pong!"}' } @test "[$TEST_FILE] post-restart login test" { - run curl_container docker_cachet_1 /auth/login --head --user test:test123 + run curl_container docker_cachet_1 :8000/auth/login --head --user test:test123 assert_output -l 0 $'HTTP/1.1 200 OK\r' } diff --git a/test/test.mysql.bats b/test/test.mysql.bats index aa63a650..fb3c2a6d 100755 --- a/test/test.mysql.bats +++ b/test/test.mysql.bats @@ -46,17 +46,17 @@ load "lib/output" } @test "[$TEST_FILE] curl 200 response test" { - run curl_container test_cachet_1 /auth/login --head + run curl_container test_cachet_1 :8000/auth/login --head assert_output -l 0 $'HTTP/1.1 200 OK\r' } @test "[$TEST_FILE] login test" { - run curl_container test_cachet_1 /auth/login --head --user test:test123 + run curl_container test_cachet_1 :8000/auth/login --head --user test:test123 assert_output -l 0 $'HTTP/1.1 200 OK\r' } @test "[$TEST_FILE] check for curl API pong" { - run curl_container test_cachet_1 /api/v1/ping + run curl_container test_cachet_1 :8000/api/v1/ping assert_output -l 0 $'{"data":"Pong!"}' } @@ -68,12 +68,12 @@ load "lib/output" } @test "[$TEST_FILE] post-restart API pong" { - run curl_container test_cachet_1 /api/v1/ping + run curl_container test_cachet_1 :8000/api/v1/ping assert_output -l 0 $'{"data":"Pong!"}' } @test "[$TEST_FILE] post-restart login test" { - run curl_container test_cachet_1 /auth/login --head --user test:test123 + run curl_container test_cachet_1 :8000/auth/login --head --user test:test123 assert_output -l 0 $'HTTP/1.1 200 OK\r' }