File tree Expand file tree Collapse file tree 5 files changed +21
-3
lines changed
Expand file tree Collapse file tree 5 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,7 @@ MAX_PARALLEL_PUBLISH=3
1212# as it is much faster to build cross-platform images.
1313# Do not uncomment this line, unless you have a depot.dev account.
1414# USE_DEPOT=1
15+
16+ # Uncomment this line if you want to add custom flags to the PHP compilation process.
17+ # For example, you can add the flag --enable-zts to complile PHP with ZTS enabled
18+ # PHP_COMPILATION_FLAGS=
Original file line number Diff line number Diff line change @@ -17,13 +17,17 @@ variable "IMAGE_VERSION_SUFFIX" {
1717variable "DOCKER_PLATFORM" {
1818 default = " linux/amd64"
1919}
20+ variable "PHP_COMPILATION_FLAGS" {
21+ default = " "
22+ }
2023
2124target "build-php" {
2225 dockerfile = " php-${ PHP_VERSION } /Dockerfile"
2326 target = " build-environment"
2427 tags = [" bref/${ CPU_PREFIX } build-php-${ PHP_VERSION } " ]
2528 args = {
2629 " IMAGE_VERSION_SUFFIX" = " ${ IMAGE_VERSION_SUFFIX } "
30+ " PHP_COMPILATION_FLAGS" = " ${ PHP_COMPILATION_FLAGS } "
2731 }
2832 platforms = [" ${ DOCKER_PLATFORM } " ]
2933}
@@ -34,6 +38,7 @@ target "php" {
3438 tags = [" bref/${ CPU_PREFIX } php-${ PHP_VERSION } " ]
3539 args = {
3640 " IMAGE_VERSION_SUFFIX" = " ${ IMAGE_VERSION_SUFFIX } "
41+ " PHP_COMPILATION_FLAGS" = " ${ PHP_COMPILATION_FLAGS } "
3742 }
3843 contexts = {
3944 " bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = " target:build-php"
Original file line number Diff line number Diff line change @@ -364,6 +364,7 @@ RUN curl --location --silent --show-error --fail https://www.php.net/get/php-${V
364364# --enable-ftp: because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
365365# --enable-mbstring: because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
366366# --with-zlib and --with-zlib-dir: See https://stackoverflow.com/a/42978649/245552
367+ ARG PHP_COMPILATION_FLAGS
367368RUN ./buildconf --force
368369RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
369370 CPPFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
@@ -398,7 +399,9 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I
398399 --enable-soap \
399400 --with-xsl=${INSTALL_DIR} \
400401 # necessary for `pecl` to work (to install PHP extensions)
401- --with-pear
402+ --with-pear \
403+ # extra compilation flags
404+ ${PHP_COMPILATION_FLAGS}
402405RUN make -j $(nproc)
403406# Run `make install` and override PEAR's PHAR URL because pear.php.net is down
404407RUN set -xe; \
Original file line number Diff line number Diff line change @@ -365,6 +365,7 @@ RUN curl --location --silent --show-error --fail https://www.php.net/get/php-${V
365365# --enable-ftp: because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
366366# --enable-mbstring: because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
367367# --with-zlib and --with-zlib-dir: See https://stackoverflow.com/a/42978649/245552
368+ ARG PHP_COMPILATION_FLAGS
368369RUN ./buildconf --force
369370RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
370371 CPPFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
@@ -399,7 +400,9 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I
399400 --enable-soap \
400401 --with-xsl=${INSTALL_DIR} \
401402 # necessary for `pecl` to work (to install PHP extensions)
402- --with-pear
403+ --with-pear \
404+ # extra compilation flags
405+ ${PHP_COMPILATION_FLAGS}
403406RUN make -j $(nproc)
404407# Run `make install` and override PEAR's PHAR URL because pear.php.net is down
405408RUN set -xe; \
Original file line number Diff line number Diff line change @@ -365,6 +365,7 @@ RUN curl --location --silent --show-error --fail https://www.php.net/get/php-${V
365365# --enable-ftp: because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
366366# --enable-mbstring: because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
367367# --with-zlib and --with-zlib-dir: See https://stackoverflow.com/a/42978649/245552
368+ ARG PHP_COMPILATION_FLAGS
368369RUN ./buildconf --force
369370RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
370371 CPPFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
@@ -399,7 +400,9 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I
399400 --enable-soap \
400401 --with-xsl=${INSTALL_DIR} \
401402 # necessary for `pecl` to work (to install PHP extensions)
402- --with-pear
403+ --with-pear \
404+ # extra compilation flags
405+ ${PHP_COMPILATION_FLAGS}
403406RUN make -j $(nproc)
404407# Run `make install` and override PEAR's PHAR URL because pear.php.net is down
405408RUN set -xe; \
You can’t perform that action at this time.
0 commit comments