From 6d05a65a02adb77f17988be0b4687c03c63f9bed Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Tue, 6 Oct 2020 11:55:37 -0400 Subject: [PATCH 1/4] Added `/cms/web/dist/*` to root `.gitignore` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1a34aba..95c6869 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ # ASSETS /cms/web/assets/* /cms/web/cpresources/* +/cms/web/dist/* # BUILD FILES node_modules From f4d2eadfd63f48293d91dbaf029039adbf67e9c7 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Tue, 6 Oct 2020 11:55:43 -0400 Subject: [PATCH 2/4] Version 2.3.14 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40fa13d..0edff6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # nystudio107/craft Change Log +## 2.3.14 - 2020.09.25 +### Added +* Added `/cms/web/dist/*` to root `.gitignore` + ## 2.3.13 - 2020.09.25 ### Added * Add `run_queue.sh` keep alive script diff --git a/composer.json b/composer.json index 87aadde..16bc41e 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "craftcms/craft", "description": "nystudio107 Craft 3.4 CMS scaffolding project", - "version": "2.3.13", + "version": "2.3.14", "keywords": [ "craft", "cms", From 80b333227b9fd4cd360a927e671b1472ef3d7517 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 25 Oct 2020 19:26:07 -0400 Subject: [PATCH 3/4] Use a separate php_xdebug container only when the XDEBUG_SESSION cookie is set, so regular requests are more performant Signed-off-by: Andrew Welch --- docker-compose.yml | 21 +++++- docker-config/nginx/default.conf | 10 ++- docker-config/php-dev-base/xdebug.ini | 4 +- docker-config/php-dev-craft/Dockerfile | 24 +----- docker-config/php-prod-base/Dockerfile | 74 +++++++++++++++++++ docker-config/php-prod-base/zzz-docker.conf | 4 + docker-config/php-prod-craft/Dockerfile | 56 ++++++++++++++ .../run_queue.sh | 0 8 files changed, 165 insertions(+), 28 deletions(-) create mode 100755 docker-config/php-prod-base/Dockerfile create mode 100755 docker-config/php-prod-base/zzz-docker.conf create mode 100755 docker-config/php-prod-craft/Dockerfile rename docker-config/{php-dev-craft => php-prod-craft}/run_queue.sh (100%) diff --git a/docker-compose.yml b/docker-compose.yml index d1e7384..825bd22 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,10 +16,10 @@ services: volumes: - cpresources:/var/www/project/cms/web/cpresources - ./cms/web:/var/www/project/cms/web:cached - # php - personal home page + # php - run php-fpm php: build: &php-build - context: ./docker-config/php-dev-craft + context: ./docker-config/php-prod-craft dockerfile: ./Dockerfile depends_on: - "mariadb" @@ -38,6 +38,23 @@ services: - ./cms:/var/www/project/cms:cached - ./cms/vendor:/var/www/project/cms/vendor:delegated - ./cms/storage/logs:/var/www/project/cms/storage/logs:delegated + # php - run php-fpm with xdebug + php_xdebug: + build: + context: ./docker-config/php-dev-craft + dockerfile: ./Dockerfile + depends_on: + - "php" + env_file: + *env + expose: + - "9000" + init: true + links: + *php-links + user: www-data + volumes: + *php-volumes # queue - runs queue jobs via php craft queue/listen queue: build: diff --git a/docker-config/nginx/default.conf b/docker-config/nginx/default.conf index b673e05..98e36fb 100755 --- a/docker-config/nginx/default.conf +++ b/docker-config/nginx/default.conf @@ -1,3 +1,11 @@ +# default Docker DNS server +resolver 127.0.0.11; + +map $cookie_XDEBUG_SESSION $my_fastcgi_pass { + default php_xdebug; + '' php; +} + server { listen 80; listen [::]:80; @@ -25,7 +33,7 @@ server { location ~ [^/]\.php(/|$) { try_files $uri $uri/ /index.php?$query_string; fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass php:9000; + fastcgi_pass $my_fastcgi_pass:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; diff --git a/docker-config/php-dev-base/xdebug.ini b/docker-config/php-dev-base/xdebug.ini index 24ada17..4a17ef8 100644 --- a/docker-config/php-dev-base/xdebug.ini +++ b/docker-config/php-dev-base/xdebug.ini @@ -1,7 +1,7 @@ xdebug.default_enable=1 xdebug.remote_enable=1 -xdebug.remote_port=9001 +xdebug.remote_port=9000 xdebug.remote_handler=dbgp -xdebug.remote_connect_back=0 +xdebug.remote_connect_back=1 xdebug.remote_host=host.docker.internal xdebug.remote_autostart=1 diff --git a/docker-config/php-dev-craft/Dockerfile b/docker-config/php-dev-craft/Dockerfile index 2a186e8..0e652fa 100755 --- a/docker-config/php-dev-craft/Dockerfile +++ b/docker-config/php-dev-craft/Dockerfile @@ -16,7 +16,7 @@ RUN apt-get update \ pdo_mysql \ && \ # Install Composer - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \ + curl -sS https://getcomposer.org/installer | php -- --version=1.10.16 --install-dir=/usr/local/bin/ --filename=composer \ # Clean apt repo caches that don't need to be part of the image && \ apt-get clean \ @@ -26,9 +26,6 @@ RUN apt-get update \ WORKDIR /var/www/project -COPY ./run_queue.sh . -RUN chmod a+x run_queue.sh - # Create the storage directory and make it writeable by PHP RUN mkdir -p /var/www/project/cms/storage && \ mkdir -p /var/www/project/cms/storage/runtime && \ @@ -39,22 +36,3 @@ RUN mkdir -p /var/www/project/cms/web/cpresources && \ chown -R www-data:www-data /var/www/project/cms/web/cpresources WORKDIR /var/www/project/cms - -# Force permissions, update Craft, and start php-fpm - -# Do a `composer install` without running any Composer scripts -# - If `composer.lock` is present, it will install what is in the lock file -# - If `composer.lock` is missing, it will update to the latest dependencies -# and create the `composer.lock` file -# This automatic running adds to the startup overhead of `docker-compose up` -# but saves far more time in not having to deal with out of sync versions -# when working with teams or multiple environments -CMD composer install --no-scripts --optimize-autoloader --no-interaction \ - && \ - chown -R www-data:www-data /var/www/project/cms/vendor \ - && \ - chown -R www-data:www-data /var/www/project/cms/storage \ - && \ - composer craft-update \ - && \ - php-fpm diff --git a/docker-config/php-prod-base/Dockerfile b/docker-config/php-prod-base/Dockerfile new file mode 100755 index 0000000..b4e4146 --- /dev/null +++ b/docker-config/php-prod-base/Dockerfile @@ -0,0 +1,74 @@ +FROM php:7.3-fpm + +# Install packages +RUN apt-get update \ + && \ + # apt Debian packages + apt-get install -y \ + apt-utils \ + autoconf \ + ca-certificates \ + curl \ + g++ \ + libbz2-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libpq-dev \ + libssl-dev \ + libicu-dev \ + libmagickwand-dev \ + libzip-dev \ + unzip \ + zip \ + && \ + # pecl PHP extensions + pecl install \ + imagick-3.4.4 \ + redis \ + && \ + # Configure PHP extensions + docker-php-ext-configure \ + gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && \ + # Install PHP extensions + docker-php-ext-install \ + bcmath \ + bz2 \ + exif \ + ftp \ + gettext \ + gd \ + iconv \ + intl \ + mbstring \ + opcache \ + pdo \ + shmop \ + sockets \ + sysvmsg \ + sysvsem \ + sysvshm \ + zip \ + && \ + # Enable PHP extensions + docker-php-ext-enable \ + imagick \ + redis \ + # Clean apt repo caches that don't need to be part of the image + && \ + apt-get clean \ + && \ + # Clean out directories that don't need to be part of the image + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Append our php.ini overrides to the end of the file +RUN echo "upload_max_filesize = 10M" > /usr/local/etc/php/php.ini && \ + echo "post_max_size = 10M" >> /usr/local/etc/php/php.ini && \ + echo "max_execution_time = 300" >> /usr/local/etc/php/php.ini && \ + echo "memory_limit = 256M" >> /usr/local/etc/php/php.ini && \ + echo "opcache.revalidate_freq = 0" >> /usr/local/etc/php/php.ini && \ + echo "opcache.validate_timestamps = 1" >> /usr/local/etc/php/php.ini + +# Copy the `zzz-docker.conf` file into place for php-fpm +COPY ./zzz-docker.conf /usr/local/etc/php-fpm.d/zzz-docker.conf diff --git a/docker-config/php-prod-base/zzz-docker.conf b/docker-config/php-prod-base/zzz-docker.conf new file mode 100755 index 0000000..1e668d5 --- /dev/null +++ b/docker-config/php-prod-base/zzz-docker.conf @@ -0,0 +1,4 @@ +[www] +pm.max_children = 10 +pm.process_idle_timeout = 10s +pm.max_requests = 1000 diff --git a/docker-config/php-prod-craft/Dockerfile b/docker-config/php-prod-craft/Dockerfile new file mode 100755 index 0000000..4a5fdd7 --- /dev/null +++ b/docker-config/php-prod-craft/Dockerfile @@ -0,0 +1,56 @@ +FROM nystudio107/php-prod-base + +# Install packages +RUN apt-get update \ + && \ + # apt Debian packages + apt-get install -y \ + nano \ + && \ + # Install PHP extensions + docker-php-ext-install \ + pdo_mysql \ + && \ + # Install Composer + curl -sS https://getcomposer.org/installer | php -- --version=1.10.16 --install-dir=/usr/local/bin/ --filename=composer \ + # Clean apt repo caches that don't need to be part of the image + && \ + apt-get clean \ + && \ + # Clean out directories that don't need to be part of the image + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +WORKDIR /var/www/project + +COPY ./run_queue.sh . +RUN chmod a+x run_queue.sh + +# Create the storage directory and make it writeable by PHP +RUN mkdir -p /var/www/project/cms/storage && \ + mkdir -p /var/www/project/cms/storage/runtime && \ + chown -R www-data:www-data /var/www/project/cms/storage + +# Create the cpresources directory and make it writeable by PHP +RUN mkdir -p /var/www/project/cms/web/cpresources && \ + chown -R www-data:www-data /var/www/project/cms/web/cpresources + +WORKDIR /var/www/project/cms + +# Force permissions, update Craft, and start php-fpm + +# Do a `composer install` without running any Composer scripts +# - If `composer.lock` is present, it will install what is in the lock file +# - If `composer.lock` is missing, it will update to the latest dependencies +# and create the `composer.lock` file +# This automatic running adds to the startup overhead of `docker-compose up` +# but saves far more time in not having to deal with out of sync versions +# when working with teams or multiple environments +CMD composer install --verbose --no-progress --no-scripts --optimize-autoloader --no-interaction \ + && \ + chown -R www-data:www-data /var/www/project/cms/vendor \ + && \ + chown -R www-data:www-data /var/www/project/cms/storage \ + && \ + composer craft-update \ + && \ + php-fpm diff --git a/docker-config/php-dev-craft/run_queue.sh b/docker-config/php-prod-craft/run_queue.sh similarity index 100% rename from docker-config/php-dev-craft/run_queue.sh rename to docker-config/php-prod-craft/run_queue.sh From 99c52ee588c2324f70b407677e9ef1ab75d690c0 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 25 Oct 2020 19:28:57 -0400 Subject: [PATCH 4/4] Version 2.3.14 Signed-off-by: Andrew Welch --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0edff6a..d381356 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # nystudio107/craft Change Log -## 2.3.14 - 2020.09.25 +## 2.3.14 - 2020.10.25 ### Added * Added `/cms/web/dist/*` to root `.gitignore` +* Use a separate php_xdebug container only when the `XDEBUG_SESSION` cookie is set, so regular requests are more performant ## 2.3.13 - 2020.09.25 ### Added