Skip to content

Commit 0b0e87e

Browse files
authored
v2: update Docker build and enable env based overrides (#225)
* update Docker build and enable env based overrides * set workflow test branch to ^11
1 parent be733ec commit 0b0e87e

File tree

4 files changed

+66
-14
lines changed

4 files changed

+66
-14
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
docker run --rm pimcore-image test ! -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
3939
fi
4040
41-
docker run --rm pimcore-image composer create-project pimcore/skeleton:11.x-dev pimcore --no-scripts
41+
docker run --rm pimcore-image composer create-project pimcore/skeleton:^11.0 pimcore --no-scripts
4242
4343
if [ "$imageVariant" != "min" ]; then
4444
docker run -v "$(pwd)/.github/files":/var/www/html --rm pimcore-image php test_heif.php
@@ -52,4 +52,4 @@ jobs:
5252
exit-code: '1'
5353
ignore-unfixed: true
5454
vuln-type: 'os,library'
55-
severity: 'CRITICAL,HIGH'
55+
severity: 'CRITICAL,HIGH'

Dockerfile

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG PHP_VERSION="8.2"
22
ARG DEBIAN_VERSION="bullseye"
33

4-
FROM php:${PHP_VERSION}-fpm-${DEBIAN_VERSION} as pimcore_php_min
4+
FROM php:${PHP_VERSION}-fpm-${DEBIAN_VERSION} AS pimcore_php_min
55

66
COPY files/build-cleanup.sh /usr/local/bin
77
COPY files/build-install.sh /usr/local/bin
@@ -30,12 +30,38 @@ RUN set -eux; \
3030

3131
RUN set -eux; build-cleanup.sh;
3232

33-
RUN echo "upload_max_filesize = 100M" >> /usr/local/etc/php/conf.d/20-pimcore.ini; \
34-
echo "memory_limit = 256M" >> /usr/local/etc/php/conf.d/20-pimcore.ini; \
35-
echo "post_max_size = 100M" >> /usr/local/etc/php/conf.d/20-pimcore.ini
36-
37-
ENV COMPOSER_ALLOW_SUPERUSER 1
38-
ENV COMPOSER_MEMORY_LIMIT -1
33+
COPY files/php.ini /usr/local/etc/php/conf.d/20-pimcore.ini
34+
COPY files/php-fpm.conf /usr/local/etc/php-fpm.d/zz-www.conf
35+
36+
# env php.ini
37+
ENV PHP_TIMEZONE="UTC"
38+
ENV PHP_MEMORY_LIMIT="256M"
39+
ENV PHP_POST_MAX_SIZE="100M"
40+
ENV PHP_UPLOAD_MAX_FILESIZE="100M"
41+
ENV PHP_DISPLAY_STARTUP_ERRORS=1
42+
ENV PHP_MAX_EXECUTION_TIME="30"
43+
ENV PHP_ERROR_REPORTING="E_ALL"
44+
ENV PHP_EXPOSE_PHP="Off"
45+
46+
# opcache settings
47+
ENV OPCACHE_ENABLE=1
48+
ENV OPCACHE_ENABLE_CLI=0
49+
ENV OPCACHE_MEMORY_CONSUMPTION=128
50+
ENV OPCACHE_MAX_ACCELERATED_FILES=10000
51+
ENV OPCACHE_VALIDATE_TIMESTAMPS=1
52+
ENV OPCACHE_CONSISTENCY_CHECKS=0
53+
54+
# fpm settings
55+
ENV PHP_FPM_LISTEN=0.0.0.0:9000
56+
ENV PHP_FPM_PM=dynamic
57+
ENV PHP_FPM_PM_MAX_CHILDREN=5
58+
ENV PHP_FPM_PM_START_SERVERS=2
59+
ENV PHP_FPM_PM_MAX_SPARE_SERVERS=3
60+
ENV PHP_FPM_PM_MIN_SPARE_SERVERS=1
61+
ENV PHP_FPM_PM_MAX_REQUESTS=10000
62+
63+
ENV COMPOSER_ALLOW_SUPERUSER=1
64+
ENV COMPOSER_MEMORY_LIMIT=-1
3965
COPY --from=composer/composer:2-bin /composer /usr/bin/composer
4066

4167
WORKDIR /var/www/html
@@ -46,7 +72,7 @@ CMD ["php-fpm"]
4672

4773

4874

49-
FROM pimcore_php_min as pimcore_php_default
75+
FROM pimcore_php_min AS pimcore_php_default
5076

5177
RUN set -eux; build-install.sh;
5278

@@ -86,7 +112,7 @@ CMD ["php-fpm"]
86112

87113

88114

89-
FROM pimcore_php_default as pimcore_php_max
115+
FROM pimcore_php_default AS pimcore_php_max
90116

91117
RUN set -eux; build-install.sh;
92118
RUN set -eux; \
@@ -103,7 +129,7 @@ CMD ["php-fpm"]
103129

104130

105131

106-
FROM pimcore_php_default as pimcore_php_debug
132+
FROM pimcore_php_default AS pimcore_php_debug
107133

108134
RUN set -eux; build-install.sh;
109135
RUN pecl install xdebug; \
@@ -113,15 +139,15 @@ RUN set -eux; build-cleanup.sh;
113139
# allow container to run as custom user, this won't work otherwise because config is changed in entrypoint.sh
114140
RUN chmod -R 0777 /usr/local/etc/php/conf.d
115141

116-
ENV PHP_IDE_CONFIG serverName=localhost
142+
ENV PHP_IDE_CONFIG=serverName=localhost
117143

118144
COPY files/entrypoint.sh /usr/local/bin
119145
RUN chmod +x /usr/local/bin/entrypoint.sh
120146

121147
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
122148
CMD ["php-fpm"]
123149

124-
FROM pimcore_php_default as pimcore_php_supervisord
150+
FROM pimcore_php_default AS pimcore_php_supervisord
125151

126152
RUN apt-get update; \
127153
apt-get install -y supervisor cron;

files/php-fpm.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; File overwrites the original values with environment variables
2+
[www]
3+
listen = ${PHP_FPM_LISTEN}
4+
pm = ${PHP_FPM_PM}
5+
pm.max_children = ${PHP_FPM_PM_MAX_CHILDREN}
6+
pm.start_servers = ${PHP_FPM_PM_START_SERVERS}
7+
pm.min_spare_servers = ${PHP_FPM_PM_MIN_SPARE_SERVERS}
8+
pm.max_spare_servers = ${PHP_FPM_PM_MAX_SPARE_SERVERS}
9+
pm.max_requests = ${PHP_FPM_PM_MAX_REQUESTS}

files/php.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
date.timezone = ${PHP_TIMEZONE}
2+
3+
memory_limit = ${PHP_MEMORY_LIMIT}
4+
max_execution_time = ${PHP_MAX_EXECUTION_TIME}
5+
error_reporting = ${PHP_ERROR_REPORTING}
6+
display_errors = ${PHP_DISPLAY_ERRORS}
7+
display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}
8+
post_max_size = ${PHP_POST_MAX_SIZE}
9+
upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}
10+
expose_php = ${PHP_EXPOSE_PHP}
11+
12+
opcache.enable = ${OPCACHE_ENABLE}
13+
opcache.enable_cli = ${OPCACHE_ENABLE_CLI}
14+
opcache.memory_consumption = ${OPCACHE_MEMORY_CONSUMPTION}
15+
opcache.max_accelerated_files = ${OPCACHE_MAX_ACCELERATED_FILES}
16+
opcache.validate_timestamps = ${OPCACHE_VALIDATE_TIMESTAMPS}
17+
opcache.consistency_checks = ${OPCACHE_CONSISTENCY_CHECKS}

0 commit comments

Comments
 (0)