From 85ef3c04af0e99ac54450b7a2b989a90b1affbe1 Mon Sep 17 00:00:00 2001 From: maxpozdeev Date: Fri, 4 Aug 2023 12:05:06 +0300 Subject: [PATCH] add docker test env with php 7.2 and postgres 10.0 --- docker/dev/mtt-php72-angie-postgres10/.env | 1 + .../mtt-php72-angie-postgres10/Dockerfile-fpm | 16 +++++ .../mtt-php72-angie-postgres10/compose.yml | 58 +++++++++++++++++++ .../php-fpm-www.conf | 12 ++++ .../mtt-php72-angie-postgres10/php-mtt.ini | 10 ++++ .../php-opcache.ini | 42 ++++++++++++++ docker/dev/mtt-php72-apache-postgres10/.env | 1 + .../mtt-php72-apache-postgres10/compose.yml | 44 ++++++++++++++ docker/dev/mtt-php72-apache/Dockerfile-web | 3 +- 9 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 docker/dev/mtt-php72-angie-postgres10/.env create mode 100644 docker/dev/mtt-php72-angie-postgres10/Dockerfile-fpm create mode 100644 docker/dev/mtt-php72-angie-postgres10/compose.yml create mode 100644 docker/dev/mtt-php72-angie-postgres10/php-fpm-www.conf create mode 100644 docker/dev/mtt-php72-angie-postgres10/php-mtt.ini create mode 100644 docker/dev/mtt-php72-angie-postgres10/php-opcache.ini create mode 100644 docker/dev/mtt-php72-apache-postgres10/.env create mode 100644 docker/dev/mtt-php72-apache-postgres10/compose.yml diff --git a/docker/dev/mtt-php72-angie-postgres10/.env b/docker/dev/mtt-php72-angie-postgres10/.env new file mode 100644 index 0000000..b32391f --- /dev/null +++ b/docker/dev/mtt-php72-angie-postgres10/.env @@ -0,0 +1 @@ +PLATFORM_NAME=mtt-dev-php72-angie-postgres10 diff --git a/docker/dev/mtt-php72-angie-postgres10/Dockerfile-fpm b/docker/dev/mtt-php72-angie-postgres10/Dockerfile-fpm new file mode 100644 index 0000000..c715a4d --- /dev/null +++ b/docker/dev/mtt-php72-angie-postgres10/Dockerfile-fpm @@ -0,0 +1,16 @@ +FROM php:7.2-fpm-alpine + +RUN apk add --no-cache postgresql-dev && \ + docker-php-ext-install pdo_mysql pdo_pgsql && \ + mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + mkdir /var/www/phpinfo && \ + echo " /var/www/phpinfo/phpinfo.php && \ + curl -o /usr/local/bin/phpunit -fL "https://phar.phpunit.de/phpunit-8.phar" && \ + chmod +x /usr/local/bin/phpunit && \ + ln -s html /var/www/src + +#COPY php-mtt.ini /usr/local/etc/php/conf.d/ +#COPY php-opcache.ini /usr/local/etc/php/conf.d/ +COPY php-fpm-www.conf /usr/local/etc/php-fpm.d/www.conf + +VOLUME /var/www/html diff --git a/docker/dev/mtt-php72-angie-postgres10/compose.yml b/docker/dev/mtt-php72-angie-postgres10/compose.yml new file mode 100644 index 0000000..1d88c50 --- /dev/null +++ b/docker/dev/mtt-php72-angie-postgres10/compose.yml @@ -0,0 +1,58 @@ +version: "3.9" + +networks: + network: + name: "${PLATFORM_NAME}-network" + +services: + web: + build: + context: ../_nginx + dockerfile: Dockerfile-angie-alpine + image: mtt-dev/angie:alpine + container_name: ${PLATFORM_NAME}-web + ports: + - "8080:80" + volumes: + - ../../../src:/var/www/html + depends_on: + - fpm + networks: + - network + + fpm: + build: + context: . + dockerfile: Dockerfile-fpm + image: mtt-dev/php:7.2-fpm-alpine + container_name: ${PLATFORM_NAME}-fpm + hostname: php-fpm + environment: + - MTT_ENABLE_DEBUG=YES + - MTT_DB_TYPE=postgres + - MTT_API_USE_PATH_INFO=YES + - MTT_DB_HOST=db + - MTT_DB_NAME=mtt + - MTT_DB_USER=mtt + - MTT_DB_PASSWORD=mtt + - MTT_DB_PREFIX=mtt_ + volumes: + - ../../../src:/var/www/html + - ../../../tests:/var/www/tests + - ./php-mtt.ini:/usr/local/etc/php/conf.d/php-mtt.ini + - ./php-opcache.ini:/usr/local/etc/php/conf.d/php-opcache.ini + networks: + - network + + db: + # do not use alpine image due to missing locales + image: postgres:10.0 + container_name: ${PLATFORM_NAME}-db + environment: + POSTGRES_PASSWORD: mtt + POSTGRES_USER: mtt + POSTGRES_DB: mtt + volumes: + - ../_postgres10/db_data:/var/lib/postgresql/data + networks: + - network diff --git a/docker/dev/mtt-php72-angie-postgres10/php-fpm-www.conf b/docker/dev/mtt-php72-angie-postgres10/php-fpm-www.conf new file mode 100644 index 0000000..b162e94 --- /dev/null +++ b/docker/dev/mtt-php72-angie-postgres10/php-fpm-www.conf @@ -0,0 +1,12 @@ +[www] +user = www-data +group = www-data +listen = 127.0.0.1:9000 +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +pm.max_requests = 500 + +access.format = "%R - %u [%t] \"%m %r\" %s %f" diff --git a/docker/dev/mtt-php72-angie-postgres10/php-mtt.ini b/docker/dev/mtt-php72-angie-postgres10/php-mtt.ini new file mode 100644 index 0000000..f9b6186 --- /dev/null +++ b/docker/dev/mtt-php72-angie-postgres10/php-mtt.ini @@ -0,0 +1,10 @@ + +; Since PHP 5.4 E_STRICT is included in E_ALL +error_reporting = E_ALL + +log_errors = On +display_errors = On +display_startup_errors = On + +cgi.fix_pathinfo=0 +session.gc_divisor = 100 diff --git a/docker/dev/mtt-php72-angie-postgres10/php-opcache.ini b/docker/dev/mtt-php72-angie-postgres10/php-opcache.ini new file mode 100644 index 0000000..2866d5c --- /dev/null +++ b/docker/dev/mtt-php72-angie-postgres10/php-opcache.ini @@ -0,0 +1,42 @@ +;; opcache.ini + +;; check /usr/local/etc/php/conf.d if exists docker-php-ext-opcache.ini + +; To disable opcache just comment this line +zend_extension=opcache.so + +[opcache] +opcache.enable=1 +opcache.enable_cli=1 + +; JIT will work only if opcache is enabled and jit_buffer_size is not zero. +; To disable JIT set the buffer size to 0. +opcache.jit_buffer_size=64M + +; JIT mode. Read more at https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit +; Default is tracing. +opcache.jit=tracing + +; The size of the shared memory storage used by OPcache, in megabytes. The minimum permissible value is "8", which is enforced if a smaller value is set. +; Default is 128. +opcache.memory_consumption=128 + +; The maximum number of keys (and therefore scripts) in the OPcache hash table. +; The actual value used will be the first number in the set of prime numbers +; { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793 } +; that is greater than or equal to the configured value. +; The minimum value is 200. The maximum value is 1000000. Values outside of this range are clamped to the permissible range. +; Default is 10000. +opcache.max_accelerated_files=1000 + +; How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request. +; This configuration directive is ignored if opcache.validate_timestamps is disabled. +; Default is 2. +opcache.revalidate_freq=2 + +; If enabled, OPcache will check for updated scripts every opcache.revalidate_freq seconds. +; When this directive is disabled, you must reset OPcache manually via opcache_reset(), opcache_invalidate() +; or by restarting the Web server for changes to the filesystem to take effect. +; Default is 1. +;; Override in docker-compose +opcache.validate_timestamps=1 diff --git a/docker/dev/mtt-php72-apache-postgres10/.env b/docker/dev/mtt-php72-apache-postgres10/.env new file mode 100644 index 0000000..927f4f3 --- /dev/null +++ b/docker/dev/mtt-php72-apache-postgres10/.env @@ -0,0 +1 @@ +PLATFORM_NAME=mtt-dev-php72-apache-postgres10 diff --git a/docker/dev/mtt-php72-apache-postgres10/compose.yml b/docker/dev/mtt-php72-apache-postgres10/compose.yml new file mode 100644 index 0000000..e903990 --- /dev/null +++ b/docker/dev/mtt-php72-apache-postgres10/compose.yml @@ -0,0 +1,44 @@ +version: "3.9" + +networks: + network: + name: "${PLATFORM_NAME}-network" + +services: + web: + build: + context: ../mtt-php72-apache/ + dockerfile: Dockerfile-web + image: mtt-dev/php:7.2-apache + container_name: ${PLATFORM_NAME}-web + ports: + - "8080:80" + environment: + - MTT_ENABLE_DEBUG=YES + - MTT_DB_TYPE=postgres + - MTT_DB_HOST=db + - MTT_DB_NAME=mtt + - MTT_DB_USER=mtt + - MTT_DB_PASSWORD=mtt + - MTT_DB_PREFIX=mtt_ + volumes: + - ../../../src:/var/www/html + - ../mtt-php72-apache/php-mtt.ini:/usr/local/etc/php/conf.d/php-mtt.ini + - ../mtt-php72-apache/php-opcache.ini:/usr/local/etc/php/conf.d/php-opcache.ini + depends_on: + - db + networks: + - network + + db: + # do not use alpine image due to missing locales + image: postgres:10.0 + container_name: ${PLATFORM_NAME}-db + environment: + POSTGRES_PASSWORD: mtt + POSTGRES_USER: mtt + POSTGRES_DB: mtt + volumes: + - ../_postgres10/db_data:/var/lib/postgresql/data + networks: + - network diff --git a/docker/dev/mtt-php72-apache/Dockerfile-web b/docker/dev/mtt-php72-apache/Dockerfile-web index 8fd0e08..d60eddc 100644 --- a/docker/dev/mtt-php72-apache/Dockerfile-web +++ b/docker/dev/mtt-php72-apache/Dockerfile-web @@ -1,6 +1,7 @@ FROM php:7.2-apache -RUN docker-php-ext-install mysqli && \ +RUN apt-get update && apt-get install -y libicu-dev libpq-dev && apt-get -y autoremove && \ + docker-php-ext-install mysqli pdo_pgsql && \ mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ mkdir /var/www/phpinfo && \ echo " /var/www/phpinfo/phpinfo.php && \