From 8aeb608b998444c28ce21ab86efeed4418414138 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Thu, 9 Sep 2021 10:54:58 +0200 Subject: [PATCH 1/2] Switch to fpm-alpine docker image, add xdebug3 --- .env | 5 ++- docker-compose.yml | 1 - php-fpm/Dockerfile | 74 +++++++++++++++++-------------------- php-fpm/error_reporting.ini | 1 + php-fpm/xdebug.ini | 3 +- 5 files changed, 41 insertions(+), 43 deletions(-) create mode 100644 php-fpm/error_reporting.ini diff --git a/.env b/.env index da7dc52..c287f44 100644 --- a/.env +++ b/.env @@ -9,8 +9,11 @@ APP_ENVIRONMENT=dev ######################################################################## # PHP ######################################################################## -PHP_XDEBUG_MODE=develop,debug +PHP_XDEBUG_MODE=debug,develop PHP_XDEBUG_CLIENT_PORT=9003 +#> LINUX: 'docker0' interface IP of host +# PHP_XDEBUG_CLIENT_HOST=1.2.3.4 +#> MAC/WIN: Docker Wildcard for host IP PHP_XDEBUG_CLIENT_HOST=host.docker.internal ######################################################################## diff --git a/docker-compose.yml b/docker-compose.yml index 55e4904..8dfa306 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,6 @@ services: APP_ENVIRONMENT: ${APP_ENVIRONMENT} ports: - "127.0.0.1:${NGINX_PORT}:80" - - "127.0.0.1:${PHP_XDEBUG_CLIENT_PORT}:${PHP_XDEBUG_CLIENT_PORT}" depends_on: - php environment: diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 9a4c7d9..6f55c28 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -1,46 +1,38 @@ -FROM alpine:3.13 +FROM php:8.0-fpm-alpine3.13 -LABEL maintainer="Vincent Composieux " - -RUN apk add --no-cache \ - coreutils \ - gettext \ - php8-fpm \ - php8-ctype \ - php8-curl \ - php8-dom \ - php8-gd \ - php8-iconv \ - php8-json \ - php8-intl \ - php8-fileinfo\ - php8-mbstring \ - php8-opcache \ - php8-openssl \ - php8-pdo \ - php8-pdo_mysql \ - php8-mysqli \ - php8-xml \ - php8-xsl \ - php8-zlib \ - php8-phar \ - php8-tokenizer \ - php8-session \ - php8-simplexml \ - php8-zip \ - php8-xmlwriter \ - php8-sodium \ - php8-pecl-apcu \ - php8-ldap \ - bash \ - make \ +RUN apk add --no-cache $PHPIZE_DEPS \ git \ - curl + gettext \ + bash \ + ldb-dev \ + libldap \ + openldap-dev + +RUN pecl install xdebug-3.0.4 \ + && docker-php-ext-enable xdebug + +RUN docker-php-ext-install ldap mysqli pdo_mysql + +# Enable php8-xdebug if $PHP_XDEBUG_MODE is not empty +ARG PHP_XDEBUG_MODE=off +ARG PHP_XDEBUG_CLIENT_PORT=5902 +ARG PHP_XDEBUG_CLIENT_HOST=host.docker.internal +COPY xdebug.ini /etc/php8/conf.d/xdebug.ini.template +RUN if [[ "$PHP_XDEBUG_MODE" != "" ]]; then \ + export PHP_XDEBUG_MODE=$PHP_XDEBUG_MODE; \ + export PHP_XDEBUG_CLIENT_PORT=$PHP_XDEBUG_CLIENT_PORT; \ + export PHP_XDEBUG_CLIENT_HOST=$PHP_XDEBUG_CLIENT_HOST; \ + envsubst < /etc/php8/conf.d/xdebug.ini.template > /etc/php8/conf.d/xdebug.ini; \ + fi +RUN rm -f /etc/php8/conf.d/xdebug.ini.template + +RUN cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini.back +RUN cp /etc/php8/conf.d/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +COPY error_reporting.ini /usr/local/etc/php/conf.d/error_reporting.ini RUN curl -sS https://getcomposer.org/installer | tee composer-setup.php \ - && php8 composer-setup.php && rm composer-setup.php* \ - && chmod +x composer.phar && mv composer.phar /usr/bin/composer \ - && ln -s /usr/bin/php8 /usr/local/bin/php + && php composer-setup.php && rm composer-setup.php* \ + && chmod +x composer.phar && mv composer.phar /usr/bin/composer ARG SYMFONY_CLI_VERSION RUN wget https://github.com/symfony/cli/releases/download/v$SYMFONY_CLI_VERSION/symfony_linux_amd64.gz \ @@ -76,6 +68,8 @@ ARG INFLUXDB_PASSWORD ARG INFLUXDB_ADMIN_TOKEN ENV INFLUXDB_URL=http://cc-influxdb:${INFLUXDB_PORT} ENV INFLUXDB_TOKEN=${INFLUXDB_ADMIN_TOKEN} +ARG LDAP_PASSWORD +ENV LDAP_PW=${LDAP_PASSWORD} ARG MYSQL_USER ARG MYSQL_PASSWORD ARG MYSQL_DATABASE @@ -85,6 +79,6 @@ ENV CORS_ALLOW_ORIGIN=^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?$ WORKDIR /var/www/symfony ENTRYPOINT ["/entrypoint.sh"] -CMD ["php-fpm8", "-F"] +CMD ["php-fpm", "-F", "-y/etc/php8/php-fpm.d/symfony.pool.conf"] EXPOSE 9001 diff --git a/php-fpm/error_reporting.ini b/php-fpm/error_reporting.ini new file mode 100644 index 0000000..7e566f4 --- /dev/null +++ b/php-fpm/error_reporting.ini @@ -0,0 +1 @@ +error_reporting=E_ALL diff --git a/php-fpm/xdebug.ini b/php-fpm/xdebug.ini index 013ad3f..d7ff8d0 100644 --- a/php-fpm/xdebug.ini +++ b/php-fpm/xdebug.ini @@ -3,4 +3,5 @@ zend_extension=xdebug.so [Xdebug] xdebug.mode=${PHP_XDEBUG_MODE} xdebug.client_port=${PHP_XDEBUG_CLIENT_PORT} -xdebug.client_host=${PHP_XDEBUG_CLIENT_HOST} \ No newline at end of file +xdebug.client_host=${PHP_XDEBUG_CLIENT_HOST} +xdebug.start_with_request=yes \ No newline at end of file From 21c4282dbc34d342cfe5b2c66263dc41d1870744 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Thu, 9 Sep 2021 11:02:25 +0200 Subject: [PATCH 2/2] Cleanup double xdebug config --- php-fpm/Dockerfile | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 2b811d9..6f55c28 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -30,19 +30,6 @@ RUN cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/co RUN cp /etc/php8/conf.d/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini COPY error_reporting.ini /usr/local/etc/php/conf.d/error_reporting.ini -# Enable php8-xdebug if $PHP_XDEBUG_MODE is not empty -ARG PHP_XDEBUG_MODE=off -ARG PHP_XDEBUG_CLIENT_PORT=5902 -ARG PHP_XDEBUG_CLIENT_HOST=host.docker.internal -COPY xdebug.ini /etc/php8/conf.d/xdebug.ini.template -RUN if [[ "$PHP_XDEBUG_MODE" != "" ]]; then \ - export PHP_XDEBUG_MODE=$PHP_XDEBUG_MODE; \ - export PHP_XDEBUG_CLIENT_PORT=$PHP_XDEBUG_CLIENT_PORT; \ - export PHP_XDEBUG_CLIENT_HOST=$PHP_XDEBUG_CLIENT_HOST; \ - envsubst < /etc/php8/conf.d/xdebug.ini.template > /etc/php8/conf.d/xdebug.ini; \ - fi -RUN rm -f /etc/php8/conf.d/xdebug.ini.template - RUN curl -sS https://getcomposer.org/installer | tee composer-setup.php \ && php composer-setup.php && rm composer-setup.php* \ && chmod +x composer.phar && mv composer.phar /usr/bin/composer