From aae0d401b8468c1b424e65deb06fdb7e4c7b4943 Mon Sep 17 00:00:00 2001 From: Dmitry Smolovich Date: Sat, 7 Dec 2019 18:53:27 -0500 Subject: [PATCH 1/3] adds phpfpmxdebug service, nginx routes debugging session calls to it see: https://jtreminio.com/blog/developing-at-full-speed-with-xdebug/ --- config/dockergento/nginx/conf/default.conf | 17 +++++++--- config/dockergento/usr/local/etc/php-fpm.conf | 31 +++++++++++++++++++ .../etc/php/conf.d/docker-php-ext-xdebug.ini | 1 + .../usr/local/etc/php/conf.d/xdebug.ini | 7 +++++ .../docker-compose.dev.mac.sample.yml | 19 ++++++++++-- docker-compose/docker-compose.sample.yml | 29 +++++++++++------ 6 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 config/dockergento/usr/local/etc/php-fpm.conf create mode 100644 config/dockergento/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini create mode 100644 config/dockergento/usr/local/etc/php/conf.d/xdebug.ini diff --git a/config/dockergento/nginx/conf/default.conf b/config/dockergento/nginx/conf/default.conf index ec0edc0..4af591e 100644 --- a/config/dockergento/nginx/conf/default.conf +++ b/config/dockergento/nginx/conf/default.conf @@ -8,8 +8,15 @@ map $http_host $MAGE_RUN_CODE { # dominio-de.lo de; } -upstream fastcgi_backend { - server unix:/sock/docker.sock; +# default Docker DNS server +resolver 127.0.0.11; + +map $cookie_XDEBUG_SESSION $my_fastcgi_pass { + default phpfpm; + XDEBUG_ECLIPSE phpfpmdebug; + PHPSTORM phpfpmdebug; + netbeans-xdebug phpfpmdebug; + macgdbp phpfpmdebug; } server { @@ -41,7 +48,7 @@ server { root $MAGE_ROOT; location ~ ^/setup/index.php { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass fastcgi_backend; + fastcgi_pass $my_fastcgi_pass:9001; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600"; @@ -68,7 +75,7 @@ server { location ~ ^/update/index.php { fastcgi_split_path_info ^(/update/index.php)(/.+)$; - fastcgi_pass fastcgi_backend; + fastcgi_pass $my_fastcgi_pass:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; @@ -174,7 +181,7 @@ server { # PHP entry point for main application location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { try_files $uri =404; - fastcgi_pass fastcgi_backend; + fastcgi_pass $my_fastcgi_pass:9001; fastcgi_buffers 1024 4k; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; diff --git a/config/dockergento/usr/local/etc/php-fpm.conf b/config/dockergento/usr/local/etc/php-fpm.conf new file mode 100644 index 0000000..5c7fcf8 --- /dev/null +++ b/config/dockergento/usr/local/etc/php-fpm.conf @@ -0,0 +1,31 @@ +; This file was initially adapated from the output of: (on PHP 5.6) +; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default + +[global] + +error_log = /proc/self/fd/2 +daemonize = no + +[www] + +; if we send this to /proc/self/fd/1, it never appears +access.log = /proc/self/fd/2 + +;user = app +;group = app + +listen = 9001 +listen.owner = app +listen.group = app +listen.mode = 0660 + +pm = dynamic +pm.max_children = 10 +pm.start_servers = 4 +pm.min_spare_servers = 2 +pm.max_spare_servers = 6 + +clear_env = no + +; Ensure worker stdout and stderr are sent to the main error log. +catch_workers_output = yes \ No newline at end of file diff --git a/config/dockergento/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini b/config/dockergento/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini new file mode 100644 index 0000000..523b629 --- /dev/null +++ b/config/dockergento/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini @@ -0,0 +1 @@ +zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so \ No newline at end of file diff --git a/config/dockergento/usr/local/etc/php/conf.d/xdebug.ini b/config/dockergento/usr/local/etc/php/conf.d/xdebug.ini new file mode 100644 index 0000000..31e1e1b --- /dev/null +++ b/config/dockergento/usr/local/etc/php/conf.d/xdebug.ini @@ -0,0 +1,7 @@ +xdebug.idekey=PHPSTORM +xdebug.remote_autostart=0 +xdebug.remote_connect_back=0 +xdebug.remote_enable=1 +xdebug.remote_host=host.docker.internal +xdebug.remote_port=9000 +xdebug.max_nesting_level=500 \ No newline at end of file diff --git a/docker-compose/docker-compose.dev.mac.sample.yml b/docker-compose/docker-compose.dev.mac.sample.yml index c37d634..71ada1c 100644 --- a/docker-compose/docker-compose.dev.mac.sample.yml +++ b/docker-compose/docker-compose.dev.mac.sample.yml @@ -1,8 +1,9 @@ version: "3.7" services: - phpfpm: - volumes: &appvolumes-mac + nginx: + volumes: + &appvolumes-mac - workspace:/var/www/html - ./app:/var/www/html/app:delegated - ./.git:/var/www/html/.git:delegated @@ -11,9 +12,20 @@ services: - ./composer.lock:/var/www/html/composer.lock:delegated # {FILES_IN_GIT} - nginx: + phpfpm: volumes: *appvolumes-mac + phpfpmdebug: + volumes: + - workspace:/var/www/html + - ./app:/var/www/html/app:delegated + - ./.git:/var/www/html/.git:delegated + - ./config:/var/www/html/config:delegated + - ./composer.json:/var/www/html/composer.json:delegated + - ./composer.lock:/var/www/html/composer.lock:delegated + - ./config/dockergento/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini:delegated + - ./config/dockergento/usr/local/etc/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini:delegated + node: volumes: *appvolumes-mac @@ -28,6 +40,7 @@ services: - SYNC_MAX_INOTIFY_WATCHES=60000 depends_on: - phpfpm + - phpfpmdebug privileged: true volumes: diff --git a/docker-compose/docker-compose.sample.yml b/docker-compose/docker-compose.sample.yml index dee9a3c..0749c09 100644 --- a/docker-compose/docker-compose.sample.yml +++ b/docker-compose/docker-compose.sample.yml @@ -1,26 +1,37 @@ version: "3.7" services: - phpfpm: - image: modestcoders/php:7.1-fpm + + nginx: + image: modestcoders/nginx:1.13 + ports: + - 80:8000 volumes: &appvolumes - - sockdata:/sock - ../.composer:/var/www/.composer:delegated - ../.composer:/var/www/html/var/composer_home:delegated - - ./config/dockergento/nginx/conf/default.conf:/var/www/conf/nginx/default.conf:delegated + - ./config/dockergento/nginx/conf/default.conf:/etc/nginx/conf.d/default.conf:delegated + - ./config/dockergento/usr/local/etc/php-fpm.conf:/usr/local/etc/php-fpm.conf:delegated + depends_on: + - phpfpm + - phpfpmdebug + + phpfpm: + image: modestcoders/php:7.2-fpm + volumes: *appvolumes environment: PHP_IDE_CONFIG: serverName=localhost depends_on: - db - elasticsearch - nginx: - image: modestcoders/nginx:1.13 - ports: - - 80:8000 + phpfpmdebug: + image: modestcoders/php:7.2-fpm volumes: *appvolumes + environment: + PHP_IDE_CONFIG: serverName=localhost depends_on: - - phpfpm + - db + - elasticsearch db: image: mysql:5.7 From 5dfd7df5662c06838da955ed0e7c736a36d2e421 Mon Sep 17 00:00:00 2001 From: Dmitry Smolovich Date: Sat, 14 Dec 2019 19:53:08 -0500 Subject: [PATCH 2/3] reverts fpm's port back to default 9000 --- config/dockergento/nginx/conf/default.conf | 6 +++--- config/dockergento/usr/local/etc/php-fpm.conf | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/dockergento/nginx/conf/default.conf b/config/dockergento/nginx/conf/default.conf index 4af591e..3bae7f5 100644 --- a/config/dockergento/nginx/conf/default.conf +++ b/config/dockergento/nginx/conf/default.conf @@ -48,7 +48,7 @@ server { root $MAGE_ROOT; location ~ ^/setup/index.php { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass $my_fastcgi_pass:9001; + fastcgi_pass $my_fastcgi_pass:9000; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600"; @@ -75,7 +75,7 @@ server { location ~ ^/update/index.php { fastcgi_split_path_info ^(/update/index.php)(/.+)$; - fastcgi_pass $my_fastcgi_pass:9001; + fastcgi_pass $my_fastcgi_pass:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; @@ -181,7 +181,7 @@ server { # PHP entry point for main application location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { try_files $uri =404; - fastcgi_pass $my_fastcgi_pass:9001; + fastcgi_pass $my_fastcgi_pass:9000; fastcgi_buffers 1024 4k; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; diff --git a/config/dockergento/usr/local/etc/php-fpm.conf b/config/dockergento/usr/local/etc/php-fpm.conf index 5c7fcf8..19e8a8d 100644 --- a/config/dockergento/usr/local/etc/php-fpm.conf +++ b/config/dockergento/usr/local/etc/php-fpm.conf @@ -14,7 +14,7 @@ access.log = /proc/self/fd/2 ;user = app ;group = app -listen = 9001 +listen = 9000 listen.owner = app listen.group = app listen.mode = 0660 From d3448b1d523e0a3a0d1abba69e02f11b58cb93dc Mon Sep 17 00:00:00 2001 From: Dmitry Smolovich Date: Sat, 14 Dec 2019 20:52:42 -0500 Subject: [PATCH 3/3] swaps back nginx and phpfpm --- .../docker-compose.dev.mac.sample.yml | 11 +++---- docker-compose/docker-compose.sample.yml | 32 ++++++++----------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/docker-compose/docker-compose.dev.mac.sample.yml b/docker-compose/docker-compose.dev.mac.sample.yml index 71ada1c..b0c0893 100644 --- a/docker-compose/docker-compose.dev.mac.sample.yml +++ b/docker-compose/docker-compose.dev.mac.sample.yml @@ -1,9 +1,8 @@ version: "3.7" services: - nginx: - volumes: - &appvolumes-mac + phpfpm: + volumes: &appvolumes-mac - workspace:/var/www/html - ./app:/var/www/html/app:delegated - ./.git:/var/www/html/.git:delegated @@ -12,9 +11,6 @@ services: - ./composer.lock:/var/www/html/composer.lock:delegated # {FILES_IN_GIT} - phpfpm: - volumes: *appvolumes-mac - phpfpmdebug: volumes: - workspace:/var/www/html @@ -26,6 +22,9 @@ services: - ./config/dockergento/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini:delegated - ./config/dockergento/usr/local/etc/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini:delegated + nginx: + volumes: *appvolumes-mac + node: volumes: *appvolumes-mac diff --git a/docker-compose/docker-compose.sample.yml b/docker-compose/docker-compose.sample.yml index 0749c09..8245fc0 100644 --- a/docker-compose/docker-compose.sample.yml +++ b/docker-compose/docker-compose.sample.yml @@ -1,37 +1,33 @@ version: "3.7" services: - - nginx: - image: modestcoders/nginx:1.13 - ports: - - 80:8000 + phpfpm: + image: modestcoders/php:7.1-fpm volumes: &appvolumes - ../.composer:/var/www/.composer:delegated - ../.composer:/var/www/html/var/composer_home:delegated - ./config/dockergento/nginx/conf/default.conf:/etc/nginx/conf.d/default.conf:delegated - ./config/dockergento/usr/local/etc/php-fpm.conf:/usr/local/etc/php-fpm.conf:delegated - depends_on: - - phpfpm - - phpfpmdebug - - phpfpm: - image: modestcoders/php:7.2-fpm - volumes: *appvolumes - environment: + environment: &phpfpmenv PHP_IDE_CONFIG: serverName=localhost - depends_on: + depends_on: &phpfpmdependencies - db - elasticsearch phpfpmdebug: image: modestcoders/php:7.2-fpm volumes: *appvolumes - environment: - PHP_IDE_CONFIG: serverName=localhost + environment: *phpfpmenv + depends_on: *phpfpmdependencies + + nginx: + image: modestcoders/nginx:1.13 + ports: + - 80:8000 + volumes: *appvolumes depends_on: - - db - - elasticsearch + - phpfpm + - phpfpmdebug db: image: mysql:5.7