J
J
johnmohnachev2018-01-18 20:08:02
PHP
johnmohnachev, 2018-01-18 20:08:02

How to run php-fpm debug mode in docker container if php-fpm is run from shell script?

I am using php-fpm image from github link
Extended it like this
Dockerfile


FROM php:5.6-fpm
WORKDIR /app
COPY php.ini /usr/local/etc/php/
RUN apt-get update \
&& apt-get install -y nano sudo redis-tools ssh libmagickwand-dev libmagickcore-dev \
&& printf "\n" | pecl install imagick \
&& docker-php-ext-install pcntl mysql mysqli pdo pdo_mysql \
&& pecl install redis-3.1.0 \
&& docker-php-ext-enable redis \
&& pecl install xdebug-2.5.0 \
&& docker-php -ext-enable xdebug
CMD ["sudo", "bash", "/app/docker/start_workers.sh"]

/app/docker/start_workers.sh

#!/bin/bash
eval "php-fpm" &
sleep 5
eval "$(echo "sudo -uwww-data php /app/cli_resque.php -start")"
while true; do sleep 1; done

PHP itself is launched, the second command is also launched, thanks to the cycle, the script does not drop out and therefore the docker does not close. But! In this mode, xdebug does not want to start. If you remove the call to this script using CMD, i.e.:

FROM php:5.6-fpm
WORKDIR /app
COPY php.ini /usr/local/etc/php/
RUN apt-get update \
&& apt-get install -y nano sudo redis-tools ssh libmagickwand-dev libmagickcore-dev \
&& printf "\n" | pecl install imagick \
&& docker-php-ext-install pcntl mysql mysqli pdo pdo_mysql \
&& pecl install redis-3.1.0 \
&& docker-php-ext-enable redis \
&& pecl install xdebug-2.5.0 \
&& docker-php -ext-enable xdebug

debug runs and works fine, but my second command from /app/docker/start_workers.sh naturally doesn't run as the script itself is no longer called.
Can anyone help in that situation? You need to either run debug or explain to the fool how to run your command after starting php-fpm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
johnmohnachev, 2018-01-19
@johnmohnachev

/app/docker/start_workers.sh
#!/bin/bash
php-fpm &
sudo -uwww-data php /app/cli_resque.php -start
while true; do sleep 1; done
Solved the problem with the missing debug. I didn’t understand exactly what it is, but the problem is in the "eval" in the bash script, or whether it launches roofing felts in some kind of magical flow, well, everything is buzzing without it. Might be useful to someone)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question