From ae8c00da7aeb9a6f696cedb89ca317918fbab5f9 Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 19 Nov 2025 17:28:56 +0100 Subject: [PATCH 1/8] delete source/downloads after building in script, not in dockerfile --- build-static.sh | 5 +++++ static-builder-gnu.Dockerfile | 7 +------ static-builder-musl.Dockerfile | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/build-static.sh b/build-static.sh index 43b3bac135..ea60c6348e 100755 --- a/build-static.sh +++ b/build-static.sh @@ -205,6 +205,11 @@ ${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTEN # shellcheck disable=SC2086 FRANKENPHP_SOURCE_DIR=${CURRENT_DIR} ${spcCommand} build --enable-zts --build-embed --build-frankenphp ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" +if [ -n "$CI" ]; then + rm -rf ./downloads + rm -rf ./source +fi + cd ../.. bin="dist/frankenphp-${os}-${arch}" diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index dea043b705..56c31c5173 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -167,9 +167,4 @@ COPY --link caddy caddy COPY --link internal internal COPY --link package package -RUN --mount=type=secret,id=github-token \ - GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \ - if [ -n "${BUILD_PACKAGES}" ]; then \ - ./build-packages.sh; \ - fi; \ - rm -Rf dist/static-php-cli/source/* +RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh \ No newline at end of file diff --git a/static-builder-musl.Dockerfile b/static-builder-musl.Dockerfile index 8a653d0be8..d388a53d60 100644 --- a/static-builder-musl.Dockerfile +++ b/static-builder-musl.Dockerfile @@ -103,6 +103,4 @@ ENV SPC_OPT_BUILD_ARGS='--with-config-file-path=/etc/frankenphp --with-config-fi ENV SPC_REL_TYPE='binary' ENV EXTENSION_DIR='/usr/lib/frankenphp/modules' -RUN --mount=type=secret,id=github-token \ - GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \ - rm -Rf dist/static-php-cli/source/* +RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh From d936f364be2425f3c2ed50a90d38a5d7992db25f Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 19 Nov 2025 17:33:39 +0100 Subject: [PATCH 2/8] add editorconfig --- .editorconfig | 13 +++++++++++++ static-builder-gnu.Dockerfile | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..4aaa886f4f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[*.sh] +indent_style = tab +tab_width = 2 + +[*.Dockerfile] +indent_style = tab +tab_width = 4 \ No newline at end of file diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index 56c31c5173..4ccc39151b 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -167,4 +167,4 @@ COPY --link caddy caddy COPY --link internal internal COPY --link package package -RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh \ No newline at end of file +RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh From 7c3c92f2030e3984afbf2e10110e5dec522dc8ac Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 19 Nov 2025 17:34:46 +0100 Subject: [PATCH 3/8] eol --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 4aaa886f4f..35774c3267 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,4 +10,4 @@ tab_width = 2 [*.Dockerfile] indent_style = tab -tab_width = 4 \ No newline at end of file +tab_width = 4 From 881e6e15ddb4e79d5f1d39050c39202c8c984b8e Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 19 Nov 2025 19:06:14 +0100 Subject: [PATCH 4/8] cs fix --- alpine.Dockerfile | 34 ++++++++++++++-------------- dev-alpine.Dockerfile | 5 ++-- static-builder-gnu.Dockerfile | 18 +++++++-------- testdata/connectionStatusLog.php | 32 +++++++++++++------------- testdata/hello.txt | 2 +- testdata/server-all-vars-ordered.php | 2 +- testdata/server-all-vars-ordered.txt | 2 +- 7 files changed, 47 insertions(+), 48 deletions(-) diff --git a/alpine.Dockerfile b/alpine.Dockerfile index c566abbc4b..8e4318db48 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -66,12 +66,12 @@ ENV GOTOOLCHAIN=local RUN apk add --no-cache --virtual .build-deps \ $PHPIZE_DEPS \ argon2-dev \ - # Needed for the custom Go build + # Needed for the custom Go build \ bash \ brotli-dev \ coreutils \ curl-dev \ - # Needed for the custom Go build + # Needed for the custom Go build \ git \ gnu-libiconv-dev \ libsodium-dev \ @@ -89,20 +89,20 @@ RUN apk add --no-cache --virtual .build-deps \ # Install e-dant/watcher (necessary for file watching) WORKDIR /usr/local/src/watcher RUN --mount=type=secret,id=github-token \ - if [ -f /run/secrets/github-token ] && [ -s /run/secrets/github-token ]; then \ - curl -s -H "Authorization: Bearer $(cat /run/secrets/github-token)" https://api.github.com/repos/e-dant/watcher/releases/latest; \ - else \ - curl -s https://api.github.com/repos/e-dant/watcher/releases/latest; \ - fi | \ - grep tarball_url | \ - awk '{ print $2 }' | \ - sed 's/,$//' | \ - sed 's/"//g' | \ - xargs curl -L | \ - tar xz --strip-components 1 && \ - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \ - cmake --build build && \ - cmake --install build + if [ -f /run/secrets/github-token ] && [ -s /run/secrets/github-token ]; then \ + curl -s -H "Authorization: Bearer $(cat /run/secrets/github-token)" https://api.github.com/repos/e-dant/watcher/releases/latest; \ + else \ + curl -s https://api.github.com/repos/e-dant/watcher/releases/latest; \ + fi | \ + grep tarball_url | \ + awk '{ print $2 }' | \ + sed 's/,$//' | \ + sed 's/"//g' | \ + xargs curl -L | \ + tar xz --strip-components 1 && \ + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \ + cmake --build build && \ + cmake --install build WORKDIR /go/src/app @@ -123,7 +123,7 @@ ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLA WORKDIR /go/src/app/caddy/frankenphp RUN GOBIN=/usr/local/bin \ - ../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \ + ../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \ setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \ ([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \ frankenphp version && \ diff --git a/dev-alpine.Dockerfile b/dev-alpine.Dockerfile index 6bc5a17cc7..a1462ef9c8 100644 --- a/dev-alpine.Dockerfile +++ b/dev-alpine.Dockerfile @@ -32,7 +32,7 @@ RUN apk add --no-cache \ zlib-dev \ bison \ nss-tools \ - # file watcher + # file watcher \ libstdc++ \ linux-headers \ # Dev tools \ @@ -49,7 +49,6 @@ RUN apk add --no-cache \ WORKDIR /usr/local/src/php RUN git clone --branch=PHP-8.4 https://github.com/php/php-src.git . && \ - # --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly ./buildconf --force && \ EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \ --enable-embed \ @@ -71,7 +70,7 @@ RUN git clone --branch=PHP-8.4 https://github.com/php/php-src.git . && \ # Install e-dant/watcher (necessary for file watching) WORKDIR /usr/local/src/watcher RUN git clone https://github.com/e-dant/watcher . && \ - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \ + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \ cmake --build build/ && \ cmake --install build diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index 4ccc39151b..7257b12c06 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -142,15 +142,15 @@ RUN if [ -n "${BUILD_PACKAGES}" ]; then \ rpm-build \ sudo \ zlib-devel && \ - curl -o ruby.tar.gz -fsSL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz && \ - tar -xzf ruby.tar.gz && \ - cd ruby-* && \ - ./configure --without-baseruby && \ - make && \ - make install && \ - cd .. && \ - rm -rf ruby* && \ - gem install fpm; \ + curl -o ruby.tar.gz -fsSL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz && \ + tar -xzf ruby.tar.gz && \ + cd ruby-* && \ + ./configure --without-baseruby && \ + make && \ + make install && \ + cd .. && \ + rm -rf ruby* && \ + gem install fpm; \ fi WORKDIR /go/src/app diff --git a/testdata/connectionStatusLog.php b/testdata/connectionStatusLog.php index a5568eb77d..80e6955dca 100644 --- a/testdata/connectionStatusLog.php +++ b/testdata/connectionStatusLog.php @@ -1,16 +1,16 @@ -"; \ No newline at end of file +echo ""; diff --git a/testdata/server-all-vars-ordered.txt b/testdata/server-all-vars-ordered.txt index 0cd81d4eb2..8b963a4333 100644 --- a/testdata/server-all-vars-ordered.txt +++ b/testdata/server-all-vars-ordered.txt @@ -30,4 +30,4 @@ REMOTE_USER:user REQUEST_METHOD:POST REQUEST_URI:/original-path?specialChars=%3E\x00%00 HTTP_X_EMPTY_HEADER: - \ No newline at end of file + From 5f74d472d3a546ff1a4cbe7acf6b1fca46aaed1d Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 19 Nov 2025 19:14:05 +0100 Subject: [PATCH 5/8] added \n there --- testdata/server-all-vars-ordered.php | 66 ++++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/testdata/server-all-vars-ordered.php b/testdata/server-all-vars-ordered.php index 8b218bd8a4..61569c835e 100644 --- a/testdata/server-all-vars-ordered.php +++ b/testdata/server-all-vars-ordered.php @@ -2,38 +2,38 @@ echo "
\n";
 foreach ([
-             'CONTENT_LENGTH',
-             'HTTP_CONTENT_LENGTH',
-             'CONTENT_TYPE',
-             'HTTP_CONTENT_TYPE',
-             'HTTP_SPECIAL_CHARS',
-             'DOCUMENT_ROOT',
-             'DOCUMENT_URI',
-             'GATEWAY_INTERFACE',
-             'HTTP_HOST',
-             'HTTPS',
-             'PATH_INFO',
-             'DOCUMENT_ROOT',
-             'REMOTE_ADDR',
-             'PHP_SELF',
-             'REMOTE_HOST',
-             'REQUEST_SCHEME',
-             'SCRIPT_FILENAME',
-             'SCRIPT_NAME',
-             'SERVER_NAME',
-             'SERVER_PORT',
-             'SERVER_PROTOCOL',
-             'SERVER_SOFTWARE',
-             'SSL_PROTOCOL',
-             'AUTH_TYPE',
-             'REMOTE_IDENT',
-             'PATH_TRANSLATED',
-             'QUERY_STRING',
-             'REMOTE_USER',
-             'REQUEST_METHOD',
-             'REQUEST_URI',
-             'HTTP_X_EMPTY_HEADER',
-         ] as $name) {
+    'CONTENT_LENGTH',
+    'HTTP_CONTENT_LENGTH',
+    'CONTENT_TYPE',
+    'HTTP_CONTENT_TYPE',
+    'HTTP_SPECIAL_CHARS',
+    'DOCUMENT_ROOT',
+    'DOCUMENT_URI',
+    'GATEWAY_INTERFACE',
+    'HTTP_HOST',
+    'HTTPS',
+    'PATH_INFO',
+    'DOCUMENT_ROOT',
+    'REMOTE_ADDR',
+    'PHP_SELF',
+    'REMOTE_HOST',
+    'REQUEST_SCHEME',
+    'SCRIPT_FILENAME',
+    'SCRIPT_NAME',
+    'SERVER_NAME',
+    'SERVER_PORT',
+    'SERVER_PROTOCOL',
+    'SERVER_SOFTWARE',
+    'SSL_PROTOCOL',
+    'AUTH_TYPE',
+    'REMOTE_IDENT',
+    'PATH_TRANSLATED',
+    'QUERY_STRING',
+    'REMOTE_USER',
+    'REQUEST_METHOD',
+    'REQUEST_URI',
+    'HTTP_X_EMPTY_HEADER',
+] as $name) {
     echo "$name:" . $_SERVER[$name] . "\n";
 }
-echo "
"; +echo "\n"; From 36e4637f8ba203b81fa7960e4bfc994a6acb158e Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 19 Nov 2025 19:21:16 +0100 Subject: [PATCH 6/8] we expect Hello\n --- caddy/caddy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/caddy_test.go b/caddy/caddy_test.go index 7ca641fdd2..7cf69bfa5e 100644 --- a/caddy/caddy_test.go +++ b/caddy/caddy_test.go @@ -407,7 +407,7 @@ func TestPHPServerDirective(t *testing.T) { `, "caddyfile") tester.AssertGetResponse("http://localhost:"+testPort, http.StatusOK, "I am by birth a Genevese (i not set)") - tester.AssertGetResponse("http://localhost:"+testPort+"/hello.txt", http.StatusOK, "Hello") + tester.AssertGetResponse("http://localhost:"+testPort+"/hello.txt", http.StatusOK, "Hello\n") tester.AssertGetResponse("http://localhost:"+testPort+"/not-found.txt", http.StatusOK, "I am by birth a Genevese (i not set)") } From 6aa8a31a4ca8190f16acbd14e237a981c6fa677b Mon Sep 17 00:00:00 2001 From: Marc Date: Thu, 20 Nov 2025 08:53:30 +0100 Subject: [PATCH 7/8] Change tab width for shell scripts to 4 spaces --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 35774c3267..ff8d338dcc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,7 @@ insert_final_newline = true [*.sh] indent_style = tab -tab_width = 2 +tab_width = 4 [*.Dockerfile] indent_style = tab From 74f43d9623dc5fe0abf2595527bf8815259714e0 Mon Sep 17 00:00:00 2001 From: Marc Date: Thu, 20 Nov 2025 09:33:59 +0100 Subject: [PATCH 8/8] bring back embed comment --- dev-alpine.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-alpine.Dockerfile b/dev-alpine.Dockerfile index a1462ef9c8..68184463b3 100644 --- a/dev-alpine.Dockerfile +++ b/dev-alpine.Dockerfile @@ -49,6 +49,7 @@ RUN apk add --no-cache \ WORKDIR /usr/local/src/php RUN git clone --branch=PHP-8.4 https://github.com/php/php-src.git . && \ + # --enable-embed is necessary to generate libphp.so, but we don't use this SAPI directly ./buildconf --force && \ EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \ --enable-embed \