From 3b7d4a144c7106ff72ad1b4fb34758d73261f629 Mon Sep 17 00:00:00 2001 From: Anatoliy Melnikov <5785276@gmail.com> Date: Wed, 27 Nov 2024 07:33:18 +0300 Subject: [PATCH 1/3] Move docker file --- Dockerfile => .docker/php/Dockerfile | 0 docker-compose.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Dockerfile => .docker/php/Dockerfile (100%) diff --git a/Dockerfile b/.docker/php/Dockerfile similarity index 100% rename from Dockerfile rename to .docker/php/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 092c671..44dc766 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: php: build: context: . - dockerfile: Dockerfile + dockerfile: .docker/php/Dockerfile args: PHP_IMAGE: ${PHP_IMAGE:-php:7.4-cli} PHP_XDEBUG_PORT: ${PHP_XDEBUG_PORT:-9003} From 9dad3668f34409e6cb09b533d078e3a2e9444ee6 Mon Sep 17 00:00:00 2001 From: Anatoliy Melnikov <5785276@gmail.com> Date: Thu, 28 Nov 2024 08:04:07 +0300 Subject: [PATCH 2/3] Refactor Docker file --- .docker/php/Dockerfile | 57 +++++++++++--------- .docker/php/conf.d/docker-php-ext-xdebug.ini | 11 ++++ 2 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 .docker/php/conf.d/docker-php-ext-xdebug.ini diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile index f234c76..d5c9bfc 100644 --- a/.docker/php/Dockerfile +++ b/.docker/php/Dockerfile @@ -1,33 +1,42 @@ -ARG PHP_IMAGE=php:7.4-cli -FROM ${PHP_IMAGE} -RUN apt-get --allow-releaseinfo-change update && apt-get install -y \ - libxml2-dev \ - libzip-dev \ - unzip \ - && docker-php-ext-install -j$(nproc) xml \ - && docker-php-ext-install -j$(nproc) zip - -# xDebug -ARG XDEBUG_VERSION=3.1.6 -ARG PHP_XDEBUG_PORT=9003 -RUN pecl install xdebug-${XDEBUG_VERSION} \ - && docker-php-ext-enable xdebug \ - && echo "xdebug.mode=coverage,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.client_host=\"host.docker.internal\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.discover_client_host=true" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.client_port=\${PHP_XDEBUG_PORT}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +ARG PHP_VERSION=8.2.7 +ARG DEBIAN_RELEASE=bullseye + +FROM php:${PHP_VERSION}-cli-${DEBIAN_RELEASE} + +ARG COMPOSER_ALLOW_SUPERUSER=1 +ARG COMPOSER_NO_INTERACTION=1 +ARG COMPOSER_VERSION=2.7.6 +ARG DEBIAN_FRONTEND=noninteractive +ARG DOCKER_PHP_DEPS='libxml2-dev libzip-dev unzip' +ARG XDEBUG_VERSION=3.2.1 + +RUN set -xe; \ + apt-get --allow-releaseinfo-change update && \ + apt-get install -y -qq ${DOCKER_PHP_DEPS} --no-install-suggests --no-install-recommends && \ + docker-php-ext-install -j$(nproc) xml && \ + docker-php-ext-install -j$(nproc) zip && \ + pecl install xdebug-${XDEBUG_VERSION} && docker-php-ext-enable xdebug && \ + rm -rf /var/lib/apt/lists/* && \ + apt-get clean + +COPY .docker/php/conf.d/*.ini /usr/local/etc/php/conf.d/ # Memory limit RUN echo "memory_limit = 1G" >> /usr/local/etc/php/php.ini -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ - && php composer-setup.php --filename composer --install-dir=/bin \ - && php -r "unlink('composer-setup.php');" \ +# Install composer +RUN set -xe; \ + curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/usr/local/bin --version=${COMPOSER_VERSION} > /dev/null 2>&1 && \ + chmod +x /usr/local/bin/composer -WORKDIR /srv/app +WORKDIR /app COPY composer.* ./ -RUN composer install --classmap-authoritative --no-autoloader --no-interaction --no-progress --no-scripts --no-suggest --prefer-dist + +RUN set -xe; \ + composer install --no-autoloader --no-dev --no-interaction --no-progress --no-scripts --no-suggest --prefer-dist && \ + composer clear-cache && \ + rm -rf ./vendor/*/*/tests + COPY ./ ./ RUN composer dump-autoload diff --git a/.docker/php/conf.d/docker-php-ext-xdebug.ini b/.docker/php/conf.d/docker-php-ext-xdebug.ini new file mode 100644 index 0000000..a86646f --- /dev/null +++ b/.docker/php/conf.d/docker-php-ext-xdebug.ini @@ -0,0 +1,11 @@ +[xdebug] +zend_extension=xdebug.so + +xdebug.mode=coverage,debug +xdebug.client_host=host.docker.internal +xdebug.client_port=9003 +xdebug.discover_client_host=true +xdebug.start_with_request=yes +xdebug.idekey=PHPSTORM +xdebug.log_level=0 +xdebug.log=/app/var/xdebug.log From 0e347e719b21f6da2e2df4c9823408c7e23a7bdd Mon Sep 17 00:00:00 2001 From: Anatoliy Melnikov <5785276@gmail.com> Date: Fri, 29 Nov 2024 08:07:23 +0300 Subject: [PATCH 3/3] Update docker-compose.yml --- compose.yaml | 10 ++++++++++ docker-compose.yml | 16 ---------------- 2 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 compose.yaml delete mode 100644 docker-compose.yml diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..829a18c --- /dev/null +++ b/compose.yaml @@ -0,0 +1,10 @@ +services: + php: + build: + context: . + dockerfile: .docker/php/Dockerfile + restart: on-failure + ports: + - "9003:9003" + volumes: + - ./:/app diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 44dc766..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3.1' - -services: - php: - build: - context: . - dockerfile: .docker/php/Dockerfile - args: - PHP_IMAGE: ${PHP_IMAGE:-php:7.4-cli} - PHP_XDEBUG_PORT: ${PHP_XDEBUG_PORT:-9003} - PHP_XDEBUG_VERSION: ${PHP_XDEBUG_VERSION:-3.1.6} - restart: on-failure - ports: - - "9003:9003" - volumes: - - ./:/srv/app