@@ -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)
4545RUN 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
4849ENV 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
6571FROM base AS php-build
@@ -88,17 +94,23 @@ RUN if [ -f ext/openssl/openssl.c ] && grep -q 'REGISTER_LONG_CONSTANT("OPENSSL_
8894
8995RUN 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
93101COPY --from=base /usr/local/lib /usr/local/lib
94102COPY --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
135152WORKDIR /usr/src
136153RUN git clone https://github.com/e-dant/watcher.git
0 commit comments