From 267488596c63bf240b32eba01b416493ae4c5988 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Fri, 24 Oct 2025 23:36:47 +0100 Subject: [PATCH] feat: upgrade static-php-cli submodule to v2.7.5 Update the static-php-cli submodule from commit 4c55f4a2 to v2.7.5 (c5ae719b). Changes made to adapt to v2.7.5: - Replace legacy Docker build script approach with spc-alpine-docker tool. - Add ext/craft.yml to configure PHP extensions (curl, filter, openssl, pcntl, phar, posix, zlib). - Update Makefile to use new build command via spc-alpine-docker. The new version uses a unified craft.yml configuration format and bin/spc tool instead of the legacy docker/ directory with manual build scripts. Co-Authored-By: Claude --- Dockerfile.php | 80 ---------------------------------------------- Makefile | 14 +++----- ext/craft.yml | 33 +++++++++++++++++++ ext/extensions.txt | 44 ------------------------- ext/static-php-cli | 2 +- 5 files changed, 38 insertions(+), 135 deletions(-) delete mode 100755 Dockerfile.php create mode 100644 ext/craft.yml delete mode 100755 ext/extensions.txt diff --git a/Dockerfile.php b/Dockerfile.php deleted file mode 100755 index cae04c1c..00000000 --- a/Dockerfile.php +++ /dev/null @@ -1,80 +0,0 @@ -FROM alpine:3.16 - -# define script basic information -# Version of this Dockerfile -ENV SCRIPT_VERSION=1.5.1 -# Download address uses backup address - -ARG USE_BACKUP_ADDRESS -ARG PHP_VERSION - -# (if downloading slowly, consider set it to yes) -ENV USE_BACKUP="${USE_BACKUP_ADDRESS}" - -# APK repositories mirror address, if u r not in China, consider set USE_BACKUP=yes to boost -ENV LINK_APK_REPO='mirrors.ustc.edu.cn' -ENV LINK_APK_REPO_BAK='dl-cdn.alpinelinux.org' - -RUN if [ "${USE_BACKUP}" = "" ]; then \ - export USE_BACKUP="no" ; \ - fi - -RUN if [ "${USE_BACKUP}" = "yes" ]; then \ - echo "Using backup original address..." ; \ - else \ - echo "Using mirror address..." && \ - sed -i 's/dl-cdn.alpinelinux.org/'${LINK_APK_REPO}'/g' /etc/apk/repositories ; \ - fi - -# build requirements -RUN apk add bash file wget cmake gcc g++ jq autoconf git libstdc++ linux-headers make m4 libgcc binutils ncurses dialog > /dev/null -# php zlib dependencies -RUN apk add zlib-dev zlib-static > /dev/null -# php mbstring dependencies -RUN apk add oniguruma-dev > /dev/null -# php openssl dependencies -RUN apk add openssl-libs-static openssl-dev openssl > /dev/null -# php gd dependencies -RUN apk add libpng-dev libpng-static > /dev/null -# curl c-ares dependencies -RUN apk add c-ares-static c-ares-dev > /dev/null -# php event dependencies -RUN apk add libevent libevent-dev libevent-static > /dev/null -# php sqlite3 dependencies -RUN apk add sqlite sqlite-dev sqlite-libs sqlite-static > /dev/null -# php libzip dependencies -RUN apk add bzip2-dev bzip2-static bzip2 > /dev/null -# php micro ffi dependencies -RUN apk add libffi libffi-dev > /dev/null -# php gd event parent dependencies -RUN apk add zstd-static > /dev/null -# php readline dependencies -RUN apk add readline-static ncurses-static readline-dev > /dev/null - -RUN mkdir /app - -WORKDIR /app - -COPY ./* /app/ - -RUN chmod +x /app/*.sh - -RUN ./download.sh swoole ${USE_BACKUP} && \ - ./download.sh inotify ${USE_BACKUP} && \ - ./download.sh mongodb ${USE_BACKUP} && \ - ./download.sh event ${USE_BACKUP} && \ - ./download.sh redis ${USE_BACKUP} && \ - ./download.sh libxml2 ${USE_BACKUP} && \ - ./download.sh xz ${USE_BACKUP} && \ - ./download.sh curl ${USE_BACKUP} && \ - ./download.sh libzip ${USE_BACKUP} && \ - ./download-git.sh dixyes/phpmicro phpmicro ${USE_BACKUP} - -RUN ./compile-deps.sh -RUN echo -e "#!/usr/bin/env bash\n/app/compile-php.sh \$@" > /bin/build-php && chmod +x /bin/build-php - -RUN /bin/build-php no-mirror $PHP_VERSION all /dist - -FROM scratch -ARG GOARCH -COPY --from=0 /dist/php /php_linux_$GOARCH diff --git a/Makefile b/Makefile index 80e15a54..ff56fefc 100644 --- a/Makefile +++ b/Makefile @@ -37,16 +37,10 @@ internal/legacy/archives/php_darwin_$(GOARCH): rm -rf $(GOOS) internal/legacy/archives/php_linux_$(GOARCH): - cp ext/extensions.txt ext/static-php-cli/docker - docker buildx build \ - --build-arg GOARCH=$(GOARCH) \ - --build-arg PHP_VERSION=$(PHP_VERSION) \ - --build-arg USE_BACKUP_ADDRESS=yes \ - --file=./Dockerfile.php \ - --platform=linux/$(GOARCH) \ - --output=type=local,dest=./internal/legacy/archives/ \ - --progress=plain \ - ext/static-php-cli/docker + mkdir -p internal/legacy/archives + cd ext/static-php-cli && SPC_USE_ARCH=$(GOARCH) ./bin/spc-alpine-docker download --with-php=$(PHP_VERSION) --for-extensions=curl,filter,openssl,pcntl,phar,posix,zlib + cd ext/static-php-cli && SPC_USE_ARCH=$(GOARCH) ./bin/spc-alpine-docker build curl,filter,openssl,pcntl,phar,posix,zlib --build-cli + cp ext/static-php-cli/buildroot/bin/php $(PHP_BINARY_PATH) PHP_WINDOWS_REMOTE_FILENAME := "php-$(PHP_VERSION)-nts-Win32-vs16-x64.zip" internal/legacy/archives/php_windows.zip: diff --git a/ext/craft.yml b/ext/craft.yml new file mode 100644 index 00000000..b028b161 --- /dev/null +++ b/ext/craft.yml @@ -0,0 +1,33 @@ +# craft.yml configuration for building PHP CLI for Upsun CLI +# This file configures static-php-cli v2.7.5+ to build a minimal PHP binary + +php-version: "8.2" + +extensions: + - curl + - filter + - openssl + - pcntl + - phar + - posix + - zlib + +libs: [] + +sapi: + - cli + +build-options: + with-clean: false + with-suggested-libs: false + with-upx-pack: true + with-strip-php: true + +download-options: + prefer-pre-built: true + retry: 5 + +craft-options: + doctor: true + download: true + build: true diff --git a/ext/extensions.txt b/ext/extensions.txt deleted file mode 100755 index 691b457e..00000000 --- a/ext/extensions.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Start with '#' is comments -# Start with '^' is deselecting extensions, which is not installed as default -# Each line just leave the extension name or ^ character - -^bcmath -^calendar -^ctype -curl -^dom -^event -^exif -^fileinfo -filter -^gd -^hash -^iconv -^inotify -^json -^libxml -^mbstring -^mongodb -^mysqlnd -openssl -pcntl -^pdo -^pdo_mysql -^pdo_sqlite -phar -posix -^protobuf -^readline -^redis -^shmop -^simplexml -^soap -^sockets -^sqlite3 -^swoole -^tokenizer -^xml -^xmlreader -^xmlwriter -zlib -^zip diff --git a/ext/static-php-cli b/ext/static-php-cli index 4c55f4a2..c5ae719b 160000 --- a/ext/static-php-cli +++ b/ext/static-php-cli @@ -1 +1 @@ -Subproject commit 4c55f4a22be0b2e130af023ef7593bcefa78314a +Subproject commit c5ae719b9c7bdb811d8f94eff42b3827e5cde1fc