diff --git a/.dockerignore b/.dockerignore index 6c1c0ff..b0ea767 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,15 +1,13 @@ -/public/bundles/ +public/bundles/ var/ vendor/ .phpunit.result.cache -/phpunit.xml +phpunit.xml -/phpunit.xml -.phpunit.result.cache +.php-cs-fixer.php +.php-cs-fixer.cache -/.php-cs-fixer.php -/.php-cs-fixer.cache .git/ .github/ .vscode/ diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index acaa6dd..0cf0932 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3-fpm-alpine AS php-system-setup +FROM php:8.3-fpm-alpine AS system-setup RUN apk --no-cache add \ curl \ @@ -7,35 +7,49 @@ RUN apk --no-cache add \ icu-dev \ zip \ libzip-dev \ - unzip + unzip \ + nginx \ + supervisor \ + $PHPIZE_DEPS && \ + pecl install apcu + +RUN curl --remote-name https://curl.se/ca/cacert.pem \ + && mv cacert.pem /etc/ssl/certs/ca-certificates.crt RUN docker-php-ext-install \ pdo \ pdo_mysql \ intl \ - zip - -RUN docker-php-ext-install opcache - -RUN apk --no-cache add $PHPIZE_DEPS && \ - pecl install apcu \ - && docker-php-ext-enable apcu - -RUN curl --remote-name https://curl.se/ca/cacert.pem \ - && mv cacert.pem /etc/ssl/certs/ca-certificates.crt + zip \ + opcache && \ + docker-php-ext-enable apcu COPY --from=composer:2.8.9 /usr/bin/composer /usr/local/bin/composer -FROM php-system-setup AS webserver-setup - -RUN apk add --update --no-cache \ - nginx \ - supervisor - COPY ./docker/main/default.conf /etc/nginx/http.d/default.conf COPY ./docker/main/supervisord.conf /etc/supervisord.conf +COPY ./docker/main/www.conf /usr/local/etc/php-fpm.d/www.conf +COPY ./docker/main/local.ini /usr/local/etc/php/conf.d/local.ini -FROM webserver-setup AS app-setup +# FPM configuration via ENV +ENV FPM_PM=dynamic +ENV FPM_PM_MAX_CHILDREN=5 +ENV FPM_PM_START_SERVERS=2 +ENV FPM_PM_MIN_SPARE_SERVERS=1 +ENV FPM_PM_MAX_SPARE_SERVERS=3 + +# PHP configuration via ENV +ENV LOG_TO_STDOUT=1 +ENV PHP_MEMORY_LIMIT=512M +ENV PHP_MAX_EXECUTION_TIME=30 +ENV PHP_UPLOAD_MAX_FILESIZE=120M +ENV PHP_POST_MAX_SIZE=128M +ENV PHP_SESSION_SAVE_HANDLER=files +ENV PHP_SESSION_SAVE_PATH= +ENV PHP_DISPLAY_ERRORS=0 +ENV PHP_DISPLAY_STARTUP_ERRORS=0 + +FROM system-setup AS app-setup COPY . /app RUN chown -R nginx:nginx /app diff --git a/docker/main/default.conf b/docker/main/default.conf index a1814f4..8f99d47 100644 --- a/docker/main/default.conf +++ b/docker/main/default.conf @@ -1,10 +1,10 @@ server { - listen 80; - index index.php; server_name localhost; root /app/public; + index index.php; + error_log /dev/stdout; access_log /dev/stdout; diff --git a/docker/main/local.ini b/docker/main/local.ini new file mode 100644 index 0000000..00adf04 --- /dev/null +++ b/docker/main/local.ini @@ -0,0 +1,9 @@ +memory_limit = ${PHP_MEMORY_LIMIT} +max_execution_time = ${PHP_MAX_EXECUTION_TIME} +upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE} +post_max_size = ${PHP_POST_MAX_SIZE} +allow_url_fopen = 1 +session.save_handler = ${PHP_SESSION_SAVE_HANDLER} +session.save_path = ${PHP_SESSION_SAVE_PATH} +display_errors = ${PHP_DISPLAY_ERRORS} +display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS} diff --git a/docker/main/www.conf b/docker/main/www.conf new file mode 100644 index 0000000..0d45d03 --- /dev/null +++ b/docker/main/www.conf @@ -0,0 +1,18 @@ +[global] +daemonize = no + +[www] +user = nginx +group = nginx +listen = 9000 +listen.owner = nginx +listen.group = nginx +listen.mode = 0660 + +pm = ${FPM_PM} +pm.max_children = ${FPM_PM_MAX_CHILDREN} +pm.start_servers = ${FPM_PM_START_SERVERS} +pm.min_spare_servers = ${FPM_PM_MIN_SPARE_SERVERS} +pm.max_spare_servers = ${FPM_PM_MAX_SPARE_SERVERS} + +catch_workers_output = yes