Skip to content

Commit 015808a

Browse files
committed
ci: add optimized release PHP variants with debug symbols
Add two new PHP variants to all bookworm CI images: - 'release-nts': Optimized non-thread-safe with debug symbols - 'release-zts': Optimized Zend thread-safe with debug symbols Both variants provide: - Full -O2 optimization for production performance - Debug symbols (-g flag) for profiling and debugging - No --enable-debug flag (avoids debug build overhead) These variants are 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-* variants - Added php-release-nts and php-release-zts build stages to all PHP version Dockerfiles (7.0-8.5) - Added both variants to final image in /opt/php/release-nts and /opt/php/release-zts Usage: switch-php release-nts # For non-thread-safe builds switch-php release-zts # For thread-safe builds
1 parent 72a021a commit 015808a

File tree

12 files changed

+91
-0
lines changed

12 files changed

+91
-0
lines changed

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 variants: 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ 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-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
73+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
7274

7375
USER root
7476

dockerfiles/ci/bookworm/php-7.1/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ 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-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
74+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
7375

7476
USER root
7577

dockerfiles/ci/bookworm/php-7.2/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ 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-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
74+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
7375

7476
USER root
7577

dockerfiles/ci/bookworm/php-7.3/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ 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-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
67+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
6668

6769
USER root
6870

dockerfiles/ci/bookworm/php-7.4/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ 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-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
73+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
7274

7375
USER root
7476

dockerfiles/ci/bookworm/php-8.0/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ 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-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
79+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
7880

7981
USER root
8082

dockerfiles/ci/bookworm/php-8.1/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,27 @@ 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-nts
74+
ARG TARGETPLATFORM
75+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release-nts $PHP_VERSION
76+
COPY build-extensions.sh /home/circleci
77+
RUN /home/circleci/build-extensions.sh
78+
79+
80+
FROM build AS php-release-zts
81+
ARG TARGETPLATFORM
82+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release-zts $PHP_VERSION
83+
COPY build-extensions.sh /home/circleci
84+
RUN /home/circleci/build-extensions.sh
85+
7386
FROM base AS final
7487
COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR
7588
COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan
7689
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7790
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7891
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
92+
COPY --chown=circleci:circleci --from=php-release-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
93+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
7994

8095
USER root
8196

dockerfiles/ci/bookworm/php-8.2/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,27 @@ 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-nts
72+
ARG TARGETPLATFORM
73+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release-nts $PHP_VERSION
74+
COPY build-extensions.sh /home/circleci
75+
RUN /home/circleci/build-extensions.sh
76+
77+
78+
FROM build AS php-release-zts
79+
ARG TARGETPLATFORM
80+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release-zts $PHP_VERSION
81+
COPY build-extensions.sh /home/circleci
82+
RUN /home/circleci/build-extensions.sh
83+
7184
FROM base AS final
7285
COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR
7386
COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan
7487
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
7588
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
7689
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
90+
COPY --chown=circleci:circleci --from=php-release-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
91+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
7792

7893
USER root
7994

dockerfiles/ci/bookworm/php-8.3/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,28 @@ 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-nts
90+
ARG TARGETPLATFORM
91+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release-nts $PHP_VERSION
92+
COPY build-extensions.sh /home/circleci
93+
RUN /home/circleci/build-extensions.sh
94+
95+
96+
FROM build AS php-release-zts
97+
ARG TARGETPLATFORM
98+
RUN /home/circleci/build-php.sh $TARGETPLATFORM $PHP_INSTALL_DIR release-zts $PHP_VERSION
99+
COPY build-extensions.sh /home/circleci
100+
RUN /home/circleci/build-extensions.sh
101+
89102
FROM base AS final
90103
COPY --chown=circleci:circleci --from=src $PHP_SRC_DIR $PHP_SRC_DIR
91104
COPY --chown=circleci:circleci --from=php-debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan $PHP_INSTALL_DIR/debug-zts-asan
92105
COPY --chown=circleci:circleci --from=php-nts-asan $PHP_INSTALL_DIR/nts-asan $PHP_INSTALL_DIR/nts-asan
93106
COPY --chown=circleci:circleci --from=php-debug $PHP_INSTALL_DIR/debug $PHP_INSTALL_DIR/debug
94107
COPY --chown=circleci:circleci --from=php-nts $PHP_INSTALL_DIR/nts $PHP_INSTALL_DIR/nts
95108
COPY --chown=circleci:circleci --from=php-zts $PHP_INSTALL_DIR/zts $PHP_INSTALL_DIR/zts
109+
COPY --chown=circleci:circleci --from=php-release-nts $PHP_INSTALL_DIR/release-nts $PHP_INSTALL_DIR/release-nts
110+
COPY --chown=circleci:circleci --from=php-release-zts $PHP_INSTALL_DIR/release-zts $PHP_INSTALL_DIR/release-zts
96111

97112
USER root
98113

0 commit comments

Comments
 (0)