Skip to content

Commit d5f2090

Browse files
committed
ci: add optimized release PHP variant with debug symbols
Add a new 'release' PHP variant to all bookworm CI images that provides: - Full -O2 optimization for production performance - Debug symbols (-g flag) for profiling and debugging - No --enable-debug flag (avoids debug build overhead) This variant is optimized for benchmarking and profiling scenarios where both performance and symbol availability are required. Changes: - Modified build-php.sh to set CFLAGS="-O2 -g" for release variant - Added php-release build stage to all PHP version Dockerfiles (7.0-8.5) - Added release variant to final image in /opt/php/release Usage: switch-php release
1 parent 72a021a commit d5f2090

12 files changed

Lines changed: 50 additions & 0 deletions

File tree

dockerfiles/ci/bookworm/build-php.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ if [[ ${INSTALL_VERSION} == *asan* ]]; then
1717
export LDFLAGS='-fsanitize=address -shared-libasan'
1818
fi
1919

20+
# Release variant: optimized with debug symbols (no --enable-debug)
21+
if [[ ${INSTALL_VERSION} == release ]]; then
22+
export CFLAGS="${CFLAGS:-} -O2 -g"
23+
fi
24+
2025
if [[ ${PHP_VERSION_ID} -le 73 ]]; then
2126
export CFLAGS="${CFLAGS:-} -Wno-implicit-function-declaration -DHAVE_POSIX_READDIR_R=1 -DHAVE_OLD_READDIR_R=0 -DTRUE=1 -DFALSE=0"
2227
export CXXFLAGS="-DTRUE=true -DFALSE=false"

dockerfiles/ci/bookworm/php-7.0/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ COPY --chown=circleci:circleci --from=php-debug-zts $PHP_INSTALL_DIR/debug-zts $
6969
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7070
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7171
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
72+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
7273

7374
USER root
7475

dockerfiles/ci/bookworm/php-7.1/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ COPY --chown=circleci:circleci --from=php-debug-zts $PHP_INSTALL_DIR/debug-zts $
7070
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7171
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7272
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
73+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
7374

7475
USER root
7576

dockerfiles/ci/bookworm/php-7.2/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ COPY --chown=circleci:circleci --from=php-debug-zts $PHP_INSTALL_DIR/debug-zts $
7070
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7171
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7272
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
73+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
7374

7475
USER root
7576

dockerfiles/ci/bookworm/php-7.3/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ COPY --chown=circleci:circleci --from=php-debug-zts $PHP_INSTALL_DIR/debug-zts $
6363
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
6464
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
6565
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
66+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
6667

6768
USER root
6869

dockerfiles/ci/bookworm/php-7.4/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-
6969
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7070
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7171
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
72+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
7273

7374
USER root
7475

dockerfiles/ci/bookworm/php-8.0/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-
7575
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7676
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7777
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
78+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
7879

7980
USER root
8081

dockerfiles/ci/bookworm/php-8.1/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,20 @@ COPY build-extensions.sh /home/circleci
7070
RUN /home/circleci/build-extensions.sh
7171
RUN cp /tmp/build-php/sapi/cli/php-asan $PHP_INSTALL_DIR/debug-zts-asan/bin/php
7272

73+
FROM build AS php-release
74+
ARG TARGETPLATFORM
75+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release $PHP_VERSION
76+
COPY build-extensions.sh /home/circleci
77+
RUN /home/circleci/build-extensions.sh
78+
79+
7380
FROM base AS final
7481
COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR
7582
COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan
7683
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7784
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7885
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
86+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
7987

8088
USER root
8189

dockerfiles/ci/bookworm/php-8.2/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,20 @@ COPY build-extensions.sh /home/circleci
6868
RUN /home/circleci/build-extensions.sh
6969
RUN cp /tmp/build-php/sapi/cli/php-asan $PHP_INSTALL_DIR/debug-zts-asan/bin/php
7070

71+
FROM build AS php-release
72+
ARG TARGETPLATFORM
73+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release $PHP_VERSION
74+
COPY build-extensions.sh /home/circleci
75+
RUN /home/circleci/build-extensions.sh
76+
77+
7178
FROM base AS final
7279
COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR
7380
COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan
7481
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7582
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7683
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
84+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
7785

7886
USER root
7987

dockerfiles/ci/bookworm/php-8.3/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,21 @@ FROM build AS php-nts-asan
8686
RUN /home/circleci/build-extensions.sh
8787
RUN mv /tmp/build-php/sapi/cli/php-asan $PHP_INSTALL_DIR/nts-asan/bin/php
8888

89+
FROM build AS php-release
90+
ARG TARGETPLATFORM
91+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release $PHP_VERSION
92+
COPY build-extensions.sh /home/circleci
93+
RUN /home/circleci/build-extensions.sh
94+
95+
8996
FROM base AS final
9097
COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR
9198
COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan
9299
COPY --chown=circleci:circleci --from=php-nts-asan $PHP_INSTALL_DIR/nts-asan $PHP_INSTALL_DIR/nts-asan
93100
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
94101
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
95102
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
103+
COPY --chown=circleci:circleci --from=php-release $PHP_INSTALL_DIR/release $PHP_INSTALL_DIR/release
96104

97105
USER root
98106

0 commit comments

Comments
 (0)