-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add separate phpfpm container dedicated to xdebug #1355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
479d380
dffe08d
b394444
508baf0
4583691
73ed8d0
fd59e15
8ccc016
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,3 @@ | ||
#!/bin/bash | ||
S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'xdebug.mode = off'); | ||
R=$(grep -c 'XDEBUG_CONFIG=idekey' ./env/phpfpm.env) | ||
|
||
if [[ -z "$2" ]] | ||
then | ||
platform="PHPSTORM" | ||
else | ||
platform=$2 | ||
fi | ||
|
||
local_debug_status(){ | ||
if [[ $R != 0 ]]; then | ||
echo "Cli debug enabled" | ||
else | ||
echo "Cli debug disabled" | ||
fi | ||
} | ||
|
||
local_debug_toggle() { | ||
if [[ $R != 0 ]]; then | ||
local_debug_disable | ||
else | ||
local_debug_enable | ||
fi | ||
} | ||
|
||
local_debug_enable() { | ||
if [[ $S == 1 ]]; then | ||
bin/xdebug enable | ||
fi | ||
|
||
if [[ $R != 0 ]]; then | ||
echo "Already enabled" | ||
exit 0 | ||
fi | ||
|
||
echo "XDEBUG_CONFIG=idekey=$platform" >> ./env/phpfpm.env | ||
sleep 1 | ||
bin/restart phpfpm | ||
echo "Cli debug enabled" | ||
} | ||
|
||
local_debug_disable() { | ||
sed -i '' '/XDEBUG_CONFIG=idekey/d' ./env/phpfpm.env | ||
sleep 1 | ||
bin/restart phpfpm | ||
echo "Cli debug disabled" | ||
} | ||
|
||
firstArgLetter="$(echo "$1" | head -c 1)" | ||
if [[ $firstArgLetter == "d" ]]; then | ||
local_debug_disable | ||
elif [[ $firstArgLetter == "e" ]]; then | ||
local_debug_enable | ||
elif [[ $firstArgLetter == "t" ]]; then | ||
local_debug_toggle | ||
elif [[ $firstArgLetter == "s" ]]; then | ||
local_debug_status | ||
else | ||
printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as mandatory argument.\nSpecify as an optional second argument the platform. Default is PHPSTORM\nEx: bin/debug-cli enable [PHPSTORM]\n" | ||
fi | ||
#!/usr/bin/env bash | ||
[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit | ||
bin/docker-compose exec phpfpm-xdebug "$@" |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,10 @@ | |
|
||
services: | ||
app: | ||
image: markoshust/magento-nginx:1.24-0 | ||
# image: markoshust/magento-nginx:1.24-0 | ||
build: | ||
context: ./images/nginx/1.24 | ||
dockerfile: Dockerfile | ||
ports: | ||
- "80:8000" | ||
- "443:8443" | ||
|
@@ -30,11 +33,25 @@ services: | |
#- "host.docker.internal:host-gateway" | ||
|
||
phpfpm: | ||
image: markoshust/magento-php:8.3-fpm-4 | ||
# image: markoshust/magento-php:8.3-fpm-4 | ||
build: | ||
context: ./images/php/8.3 | ||
dockerfile: Dockerfile | ||
Comment on lines
+36
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @markshust This should be replaced with dedicated image build |
||
volumes: *appvolumes | ||
env_file: env/phpfpm.env | ||
#extra_hosts: *appextrahosts | ||
|
||
phpfpm-xdebug: | ||
# image: markoshust/magento-php:8.3-fpm-4 | ||
build: | ||
context: ./images/php/8.3-xdebug | ||
dockerfile: Dockerfile | ||
Comment on lines
+45
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @markshust This should be replaced with dedicated image build |
||
volumes: *appvolumes | ||
env_file: | ||
- env/phpfpm.env | ||
- env/phpfpm-xdebug.env | ||
#extra_hosts: *appextrahosts | ||
|
||
db: | ||
image: mariadb:11.4 | ||
command: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PHP_IDE_CONFIG="serverName=docker-magento" | ||
XDEBUG_MODE=develop,debug |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
upstream fastcgi_backend { | ||
server unix:/sock/docker.sock; | ||
upstream fastcgi_phpfpm { | ||
server unix:/sock/phpfpm.sock; | ||
} | ||
|
||
upstream fastcgi_phpfpm_xdebug { | ||
server unix:/sock/phpfpm-xdebug.sock; | ||
} | ||
|
||
map $cookie_XDEBUG_SESSION $fastcgi_backend { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem I mentioned in the description is that mapping requires to put
but it should be
The occurence is repeated 3 times - perhaps some post-script with |
||
default fastcgi_phpfpm; | ||
PHPSTORM fastcgi_phpfpm_xdebug; | ||
} | ||
|
||
server { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
FROM php:8.3-fpm-bookworm | ||
LABEL maintainer="Mark Shust <[email protected]>" | ||
|
||
ARG APP_ID=1000 | ||
RUN groupadd -g "$APP_ID" app \ | ||
&& useradd -g "$APP_ID" -u "$APP_ID" -d /var/www -s /bin/bash app | ||
|
||
RUN mkdir -p /etc/nginx/html /var/www/html /sock \ | ||
&& chown -R app:app /etc/nginx /var/www /usr/local/etc/php/conf.d /sock | ||
|
||
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
cron \ | ||
default-mysql-client \ | ||
git \ | ||
gnupg \ | ||
gzip \ | ||
libbz2-dev \ | ||
libfreetype6-dev \ | ||
libicu-dev \ | ||
libjpeg62-turbo-dev \ | ||
libmagickwand-dev \ | ||
libmcrypt-dev \ | ||
libonig-dev \ | ||
libpng-dev \ | ||
libsodium-dev \ | ||
libssh2-1-dev \ | ||
libwebp-dev \ | ||
libxslt1-dev \ | ||
libzip-dev \ | ||
lsof \ | ||
mailutils \ | ||
msmtp \ | ||
nodejs \ | ||
procps \ | ||
rsync \ | ||
strace \ | ||
vim \ | ||
zip \ | ||
zlib1g-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pecl channel-update pecl.php.net && pecl install \ | ||
redis-6.2.0 \ | ||
ssh2-1.4.1 \ | ||
swoole-6.0.2 \ | ||
xdebug-3.4.2 \ | ||
imagick-3.8.0RC2 \ | ||
&& pecl clear-cache \ | ||
&& rm -rf /tmp/pear | ||
|
||
RUN docker-php-ext-configure \ | ||
gd --with-freetype --with-jpeg --with-webp \ | ||
&& docker-php-ext-install \ | ||
bcmath \ | ||
bz2 \ | ||
calendar \ | ||
exif \ | ||
ftp \ | ||
gd \ | ||
gettext \ | ||
intl \ | ||
mbstring \ | ||
mysqli \ | ||
opcache \ | ||
pcntl \ | ||
pdo_mysql \ | ||
soap \ | ||
sockets \ | ||
sodium \ | ||
sysvmsg \ | ||
sysvsem \ | ||
sysvshm \ | ||
xsl \ | ||
zip \ | ||
&& docker-php-ext-enable \ | ||
imagick \ | ||
redis \ | ||
ssh2 \ | ||
xdebug | ||
|
||
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ | ||
&& architecture=$(uname -m) \ | ||
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/$architecture/$version \ | ||
&& mkdir -p /tmp/blackfire \ | ||
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ | ||
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \ | ||
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz | ||
|
||
RUN git clone --branch v0.4.18 --depth=1 https://github.com/NoiseByNorthwest/php-spx.git /usr/lib/php-spx \ | ||
&& cd /usr/lib/php-spx \ | ||
&& phpize \ | ||
&& ./configure \ | ||
&& make \ | ||
&& make install | ||
|
||
RUN curl -sS https://getcomposer.org/installer | \ | ||
php -- --version=2.8.6 --install-dir=/usr/local/bin --filename=composer | ||
|
||
COPY conf/blackfire.ini $PHP_INI_DIR/conf.d/blackfire.ini | ||
COPY conf/spx.ini $PHP_INI_DIR/conf.d/spx.ini | ||
COPY conf/msmtprc /etc/msmtprc | ||
COPY conf/php.ini $PHP_INI_DIR | ||
COPY conf/php-xdebug.ini $PHP_INI_DIR/conf.d/ | ||
COPY conf/php-fpm.conf /usr/local/etc/ | ||
COPY conf/www.conf /usr/local/etc/php-fpm.d/ | ||
|
||
USER app:app | ||
VOLUME /var/www | ||
WORKDIR /var/www/html |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
extension=blackfire.so | ||
blackfire.agent_socket=tcp://blackfire:8307 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
account default | ||
host mailcatcher | ||
port 1025 | ||
from "[email protected]" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
; This file was initially adapted 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 = /sock/phpfpm-xdebug.sock | ||
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 | ||
|
||
; This needed to make PHP-SPX work in fpm mode. | ||
process.dumpable = yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markshust This should be replaced with dedicated image build