packages/

php

Details
Source
FROM scratch AS base
ARG ARCH=x86_64
ENV PKG_NAME=php83
ENV VERSION=8.3.4
ENV SRC_HASH=4e633d4709afa5301d84d3821471bfb136f281bb71f9acca2fe9d29cc0407d2a
ENV SRC_FILE=php-${VERSION}.tar.gz
ENV SRC_SITE=https://github.com/php/php-src/archive/refs/tags/${SRC_FILE}

FROM base AS fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .

FROM fetch AS build
COPY --from=stagex/libunwind . /
COPY --from=stagex/acl . /
COPY --from=stagex/automake . /
COPY --from=stagex/bash . /
COPY --from=stagex/bc . /
COPY --from=stagex/busybox . /
COPY --from=stagex/libzstd . /
COPY --from=stagex/lld . /
COPY --from=stagex/binutils . /
COPY --from=stagex/llvm . /
COPY --from=stagex/curl . /
COPY --from=stagex/clang . /
COPY --from=stagex/bison . /
COPY --from=stagex/gdbm . /
COPY --from=stagex/lmdb . /
COPY --from=stagex/pkgconf . /
COPY --from=stagex/autoconf . /
COPY --from=stagex/make . /
COPY --from=stagex/gcc . /
COPY --from=stagex/gmp . /
COPY --from=stagex/icu . /
COPY --from=stagex/gettext . /
COPY --from=stagex/openssl . /
COPY --from=stagex/expat . /
COPY --from=stagex/libxml2 . /
COPY --from=stagex/re2c . /
COPY --from=stagex/musl . /
COPY --from=stagex/perl . /
COPY --from=stagex/m4 . /
COPY --from=stagex/zlib . /
COPY --from=stagex/lzip . /
COPY --from=stagex/pcre2 . /
COPY --from=stagex/bzip2 . /
COPY --from=stagex/python . /
COPY --from=stagex/libedit . /
COPY --from=stagex/linux-headers . /
COPY --from=stagex/sqlite3 . /
RUN tar -xf php-${VERSION}.tar.gz
WORKDIR /php-src-php-${VERSION}
COPY *.patch .
ENV SOURCE_DATE_EPOCH=1
ENV PHP_UNAME="Linux stagex"
ENV PHP_BUILD_SYSTEM="${PHP_UNAME}"
RUN --network=none <<-EOF
	set -eux
	export CFLAGS="-O2"
	export CXXFLAGS="-O2"
	patch -p1 fix-lfs64-2.patch
	patch -p1 fix-tests-devserver.patch
	patch -p1 includedir.patch
	patch -p1 install-pear.patch
	patch -p1 php83-fpm-verison-suffix.patch
	patch -p1 phpinfo-avif.patch
	patch -p1 sharedir.patch
	export CC=clang-18
	export CXX=clang++-18
	./buildconf --force
	EXTENSION_DIR=/usr/lib/modules ./configure \
		--build=x86_64-linux-musl \
		--host=x86_64-linux-musl \
		--prefix=/usr \
		--program-suffix=php83#php \
		--libdir=/usr/lib \
		--datadir=/usr/share/php83 \
		--sysconfdir=/etc/php83 \
		--localstatedir=/var \
		--with-layout=GNU \
		--with-pic \
		--with-config-file-path=/etc/php83 \
		--with-config-file-scan-dir=/etc/php83/conf.d \
		--disable-rpath \
		--disable-short-tags \
		\
		--disable-all \
		--enable-bcmath=shared \
		--with-bz2=shared \
		--enable-calendar=shared \
		--enable-ctype=shared \
		--with-curl=shared \
		# --enable-dba=shared \
		# 	--with-dbmaker=shared \
		# 	--with-gdbm \
		# 	--with-lmdb \
		# --enable-dom=shared \
		# --with-enchant=shared \
		# --enable-exif=shared \
		# --with-ffi=shared \
		# --enable-fileinfo=shared \
		# --enable-ftp=shared \
		# --enable-gd=shared \
		# 	--with-avif \
		# 	--with-freetype \
		# 	--with-jpeg \
		# 	--with-webp \
		# 	--with-xpm \
		# 	--disable-gd-jis-conv \
		# --with-gettext=shared \
		# --with-gmp=shared \
		# --with-iconv=shared \
		# --with-imap=shared \
		# 	--with-imap-ssl \
		# --enable-intl=shared \
		# --with-ldap=shared \
		# 	--with-ldap-sasl \
		# --with-libedit \
		# --with-libxml \
		# --enable-mbstring=shared \
		# --with-mysqli=shared \
		# 	--with-mysql-sock=/run/mysqld/mysqld.sock \
		# --enable-mysqlnd=shared \
		# --enable-opcache=shared \
		# --with-openssl=shared  \
		# 	--with-kerberos \
		# 	--with-system-ciphers \
		# --with-password-argon2 \
		# --enable-pcntl=shared \
		# --with-external-pcre \
		# 	#$without_pcre_jit \
		# --enable-pdo=shared \
		# 	--with-pdo-dblib=shared,/usr \
		# 	--with-pdo-mysql=shared,mysqlnd \
		# 	--with-pdo-odbc=shared,unixODBC,/usr \
		# 	--with-pdo-pgsql=shared \
		# 	--with-pdo-sqlite=shared \
		# --with-pgsql=shared \
		# --enable-phar=shared \
		# --enable-posix=shared \
		# --with-pspell=shared \
		# --without-readline \
		# --enable-session=shared \
		# --enable-shmop=shared \
		# --enable-simplexml=shared \
		# --with-snmp=shared \
		# --enable-soap=shared \
		# --with-sodium=shared \
		# --enable-sockets=shared \
		# --with-sqlite3=shared \
		# --enable-sysvmsg=shared \
		# --enable-sysvsem=shared \
		# --enable-sysvshm=shared \
		# --with-tidy=shared \
		# --enable-tokenizer=shared \
		# --with-unixODBC=shared,/usr \
		# --enable-xml=shared \
		# --enable-xmlreader=shared \
		# --enable-xmlwriter=shared \
		# --with-xsl=shared \
		# --with-zip=shared \
		# --with-zlib \
		# --enable-zend-test=shared \
		"$@"
    make -j "$(nproc)"
EOF

FROM build AS install
RUN --network=none make INSTALL_ROOT=/rootfs install

FROM build AS test
RUN /bin/sh -c 'set -eux; \
	if ! make TEST_PHP_ARGS=-j$(nproc) test; then \
		echo "PHP test failed"; \
		exit 1; \
	fi'

FROM stagex/filesystem AS package
COPY --from=stagex/busybox . /
USER root
RUN rm -rf /var/run
RUN mkdir -p /var && mkdir -p /var/run && chown -R root:root /var/run && chmod -R 755 /var/run
COPY --from=install /rootfs/. /