Skip to content

Commit 2df2e2f

Browse files
committed
+
1 parent 7255eb1 commit 2df2e2f

File tree

2 files changed

+90
-56
lines changed

2 files changed

+90
-56
lines changed

.github/workflows/Dockerfile.centos-php-test-zts

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,28 @@ RUN yum install -y autoconf bison pkgconfig \
4444
# Install mariadb-devel separately (may need different repo or skip if not critical)
4545
RUN yum install -y mariadb-devel || yum install -y mariadb-connector-c-devel || echo "Warning: mariadb-devel not available, continuing without it"
4646

47-
# Build and install lexbor library (STATIC - embedded into libphp.so)
47+
# Build and install lexbor library (STATIC - embedded into libphp.so) - only for PHP 8.4+
48+
ARG PHP_VERSION
4849
ENV LEXBOR_VERSION=2.4.0
49-
RUN git clone --depth 1 --branch v${LEXBOR_VERSION} https://github.com/lexbor/lexbor.git /tmp/lexbor-src && \
50-
cd /tmp/lexbor-src && \
51-
cmake -S . -B build \
52-
-DCMAKE_BUILD_TYPE=Release \
53-
-DCMAKE_INSTALL_PREFIX=/usr/local \
54-
-DLEXBOR_BUILD_SHARED=OFF \
55-
-DLEXBOR_BUILD_STATIC=ON \
56-
-DLEXBOR_INSTALL_HEADERS=ON && \
57-
cmake --build build && \
58-
cmake --install build && \
59-
echo "Lexbor STATIC library installed:" && \
60-
ls -la /usr/local/lib*/liblexbor* || true && \
61-
ls -la /usr/local/include/lexbor/ || true && \
62-
rm -rf /tmp/lexbor-src
50+
RUN if [ "$(echo "${PHP_VERSION}" | cut -d. -f1)" -ge 8 ] && [ "$(echo "${PHP_VERSION}" | cut -d. -f2)" -ge 4 ]; then \
51+
echo "Building lexbor for PHP ${PHP_VERSION} (8.4+)"; \
52+
git clone --depth 1 --branch v${LEXBOR_VERSION} https://github.com/lexbor/lexbor.git /tmp/lexbor-src && \
53+
cd /tmp/lexbor-src && \
54+
cmake -S . -B build \
55+
-DCMAKE_BUILD_TYPE=Release \
56+
-DCMAKE_INSTALL_PREFIX=/usr/local \
57+
-DLEXBOR_BUILD_SHARED=OFF \
58+
-DLEXBOR_BUILD_STATIC=ON \
59+
-DLEXBOR_INSTALL_HEADERS=ON && \
60+
cmake --build build && \
61+
cmake --install build && \
62+
echo "Lexbor STATIC library installed:" && \
63+
ls -la /usr/local/lib*/liblexbor* || true && \
64+
ls -la /usr/local/include/lexbor/ || true && \
65+
rm -rf /tmp/lexbor-src; \
66+
else \
67+
echo "Skipping lexbor build for PHP ${PHP_VERSION} (< 8.4)"; \
68+
fi
6369

6470
# Fetch and build PHP from source with ZTS
6571
FROM base AS php-build
@@ -88,17 +94,23 @@ RUN if [ -f ext/openssl/openssl.c ] && grep -q 'REGISTER_LONG_CONSTANT("OPENSSL_
8894

8995
RUN mkdir -p /usr/local/etc/php/conf.d
9096

91-
# Copy lexbor static library and headers from base stage
92-
COPY --from=base /usr/local/include/lexbor /usr/local/include/lexbor
97+
# Copy lexbor static library and headers from base stage (only if PHP 8.4+)
98+
ARG PHP_VERSION
99+
RUN if [ -d /tmp/dummy ]; then mkdir -p /usr/local/include/lexbor /usr/local/lib64; fi
100+
COPY --from=base /usr/local/include/lexbor* /usr/local/include/ 2>/dev/null || true
93101
COPY --from=base /usr/local/lib /usr/local/lib
94102
COPY --from=base /usr/local/lib64 /usr/local/lib64
95103

96-
# Build PHP with ZTS enabled and statically link lexbor
97-
RUN export CFLAGS="-I/usr/local/include" && \
98-
export LDFLAGS="-L/usr/local/lib -L/usr/local/lib64" && \
99-
export LIBS="/usr/local/lib64/liblexbor_static.a" && \
100-
echo "Building PHP with static lexbor:" && \
101-
ls -lh /usr/local/lib*/liblexbor* && \
104+
# Build PHP with ZTS enabled and conditionally link lexbor for PHP 8.4+
105+
RUN if [ -f /usr/local/lib64/liblexbor_static.a ]; then \
106+
echo "Building PHP ${PHP_VERSION} with static lexbor (8.4+)"; \
107+
export CFLAGS="-I/usr/local/include"; \
108+
export LDFLAGS="-L/usr/local/lib -L/usr/local/lib64"; \
109+
export LIBS="/usr/local/lib64/liblexbor_static.a"; \
110+
ls -lh /usr/local/lib*/liblexbor* || true; \
111+
else \
112+
echo "Building PHP ${PHP_VERSION} without lexbor (< 8.4)"; \
113+
fi && \
102114
./configure \
103115
--prefix=/usr/local \
104116
--with-config-file-path=/usr/local/lib \
@@ -126,11 +138,16 @@ RUN export CFLAGS="-I/usr/local/include" && \
126138
&& make install \
127139
&& strip /usr/local/bin/php /usr/local/sbin/php-fpm || true
128140

129-
# Verify lexbor symbols are embedded in libphp.so
130-
RUN echo "Checking if libphp.so has EMBEDDED lexbor symbols (static linking):" && \
131-
nm /usr/local/lib/libphp.so | grep lxb_ | head -n 5 && \
132-
echo "✓ Lexbor symbols found - static linking successful!" || \
133-
echo "✗ WARNING: No lexbor symbols found in libphp.so"
141+
# Verify lexbor symbols are embedded in libphp.so (only for PHP 8.4+)
142+
ARG PHP_VERSION
143+
RUN if [ "$(echo "${PHP_VERSION}" | cut -d. -f1)" -ge 8 ] && [ "$(echo "${PHP_VERSION}" | cut -d. -f2)" -ge 4 ]; then \
144+
echo "Checking if libphp.so has EMBEDDED lexbor symbols (PHP ${PHP_VERSION}):" && \
145+
nm /usr/local/lib/libphp.so | grep lxb_ | head -n 5 && \
146+
echo "✓ Lexbor symbols found - static linking successful!" || \
147+
echo "✗ WARNING: No lexbor symbols found in libphp.so"; \
148+
else \
149+
echo "Skipping lexbor verification for PHP ${PHP_VERSION} (< 8.4)"; \
150+
fi
134151

135152
WORKDIR /usr/src
136153
RUN git clone https://github.com/e-dant/watcher.git

.github/workflows/Dockerfile.ubuntu-php-test-zts

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,28 @@ RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
3333
echo "${TZ}" > /etc/timezone && \
3434
dpkg-reconfigure -f noninteractive tzdata
3535

36-
# Build and install lexbor library (STATIC - embedded into libphp.so)
36+
# Build and install lexbor library (STATIC - embedded into libphp.so) - only for PHP 8.4+
37+
ARG PHP_VERSION
3738
ENV LEXBOR_VERSION=2.4.0
38-
RUN git clone --depth 1 --branch v${LEXBOR_VERSION} https://github.com/lexbor/lexbor.git /tmp/lexbor-src && \
39-
cd /tmp/lexbor-src && \
40-
cmake -S . -B build \
41-
-DCMAKE_BUILD_TYPE=Release \
42-
-DCMAKE_INSTALL_PREFIX=/usr/local \
43-
-DLEXBOR_BUILD_SHARED=OFF \
44-
-DLEXBOR_BUILD_STATIC=ON \
45-
-DLEXBOR_INSTALL_HEADERS=ON && \
46-
cmake --build build && \
47-
cmake --install build && \
48-
echo "Lexbor STATIC library installed:" && \
49-
ls -la /usr/local/lib*/liblexbor* || true && \
50-
ls -la /usr/local/include/lexbor/ || true && \
51-
rm -rf /tmp/lexbor-src
39+
RUN if [ "$(echo "${PHP_VERSION}" | cut -d. -f1)" -ge 8 ] && [ "$(echo "${PHP_VERSION}" | cut -d. -f2)" -ge 4 ]; then \
40+
echo "Building lexbor for PHP ${PHP_VERSION} (8.4+)"; \
41+
git clone --depth 1 --branch v${LEXBOR_VERSION} https://github.com/lexbor/lexbor.git /tmp/lexbor-src && \
42+
cd /tmp/lexbor-src && \
43+
cmake -S . -B build \
44+
-DCMAKE_BUILD_TYPE=Release \
45+
-DCMAKE_INSTALL_PREFIX=/usr/local \
46+
-DLEXBOR_BUILD_SHARED=OFF \
47+
-DLEXBOR_BUILD_STATIC=ON \
48+
-DLEXBOR_INSTALL_HEADERS=ON && \
49+
cmake --build build && \
50+
cmake --install build && \
51+
echo "Lexbor STATIC library installed:" && \
52+
ls -la /usr/local/lib*/liblexbor* || true && \
53+
ls -la /usr/local/include/lexbor/ || true && \
54+
rm -rf /tmp/lexbor-src; \
55+
else \
56+
echo "Skipping lexbor build for PHP ${PHP_VERSION} (< 8.4)"; \
57+
fi
5258

5359
# Fetch and build PHP from source with ZTS
5460
FROM base AS php-build
@@ -82,16 +88,22 @@ RUN a2dismod mpm_event || true && \
8288
a2dismod mpm_worker || true && \
8389
a2enmod mpm_prefork rewrite cgi cgid || true
8490

85-
# Copy lexbor static library and headers from base stage
86-
COPY --from=base /usr/local/include/lexbor /usr/local/include/lexbor
91+
# Copy lexbor static library and headers from base stage (only if PHP 8.4+)
92+
ARG PHP_VERSION
93+
RUN mkdir -p /usr/local/include /usr/local/lib
94+
COPY --from=base /usr/local/include/lexbor* /usr/local/include/ 2>/dev/null || true
8795
COPY --from=base /usr/local/lib /usr/local/lib
8896

89-
# Build PHP with ZTS enabled and statically link lexbor
90-
RUN export CFLAGS="-I/usr/local/include" && \
91-
export LDFLAGS="-L/usr/local/lib" && \
92-
export LIBS="/usr/local/lib/liblexbor_static.a" && \
93-
echo "Building PHP with static lexbor:" && \
94-
ls -lh /usr/local/lib/liblexbor* && \
97+
# Build PHP with ZTS enabled and conditionally link lexbor for PHP 8.4+
98+
RUN if [ -f /usr/local/lib/liblexbor_static.a ]; then \
99+
echo "Building PHP ${PHP_VERSION} with static lexbor (8.4+)"; \
100+
export CFLAGS="-I/usr/local/include"; \
101+
export LDFLAGS="-L/usr/local/lib"; \
102+
export LIBS="/usr/local/lib/liblexbor_static.a"; \
103+
ls -lh /usr/local/lib/liblexbor* || true; \
104+
else \
105+
echo "Building PHP ${PHP_VERSION} without lexbor (< 8.4)"; \
106+
fi && \
95107
./configure \
96108
--prefix=/usr/local \
97109
--with-config-file-path=/usr/local/lib \
@@ -119,11 +131,16 @@ RUN export CFLAGS="-I/usr/local/include" && \
119131
&& make install \
120132
&& strip /usr/local/bin/php /usr/local/sbin/php-fpm || true
121133

122-
# Verify lexbor symbols are embedded in libphp.so
123-
RUN echo "Checking if libphp.so has EMBEDDED lexbor symbols (static linking):" && \
124-
nm /usr/local/lib/libphp.so | grep lxb_ | head -n 5 && \
125-
echo "✓ Lexbor symbols found - static linking successful!" || \
126-
echo "✗ WARNING: No lexbor symbols found in libphp.so"
134+
# Verify lexbor symbols are embedded in libphp.so (only for PHP 8.4+)
135+
ARG PHP_VERSION
136+
RUN if [ "$(echo "${PHP_VERSION}" | cut -d. -f1)" -ge 8 ] && [ "$(echo "${PHP_VERSION}" | cut -d. -f2)" -ge 4 ]; then \
137+
echo "Checking if libphp.so has EMBEDDED lexbor symbols (PHP ${PHP_VERSION}):" && \
138+
nm /usr/local/lib/libphp.so | grep lxb_ | head -n 5 && \
139+
echo "✓ Lexbor symbols found - static linking successful!" || \
140+
echo "✗ WARNING: No lexbor symbols found in libphp.so"; \
141+
else \
142+
echo "Skipping lexbor verification for PHP ${PHP_VERSION} (< 8.4)"; \
143+
fi
127144

128145
WORKDIR /usr/src
129146
RUN git clone https://github.com/e-dant/watcher.git

0 commit comments

Comments
 (0)