From 9d4096dea1d46a7db4117d065552c1fba832a64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 8 May 2025 20:19:05 +0200 Subject: [PATCH 1/9] fix: use local Go toolchain --- .github/workflows/sanitizers.yaml | 2 ++ .github/workflows/static.yaml | 1 + .github/workflows/tests.yaml | 2 ++ Dockerfile | 1 + alpine.Dockerfile | 1 + caddy/caddy.go | 2 +- caddy/caddy_test.go | 31 +++++++++++++++++++++++++++++++ dev-alpine.Dockerfile | 1 + dev.Dockerfile | 1 + static-builder-gnu.Dockerfile | 3 ++- static-builder-musl.Dockerfile | 2 ++ 11 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sanitizers.yaml b/.github/workflows/sanitizers.yaml index 8def2f18be..c4ade4a6a3 100644 --- a/.github/workflows/sanitizers.yaml +++ b/.github/workflows/sanitizers.yaml @@ -13,6 +13,8 @@ on: - "docs/**" permissions: contents: read +env: + GOTOOLCHAIN: local jobs: # Adapted from https://github.com/beberlei/hdrhistogram-php sanitizers: diff --git a/.github/workflows/static.yaml b/.github/workflows/static.yaml index 39adb5d949..e4256f06f8 100644 --- a/.github/workflows/static.yaml +++ b/.github/workflows/static.yaml @@ -29,6 +29,7 @@ permissions: attestations: write env: IMAGE_NAME: ${{ (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.version) || startsWith(github.ref, 'refs/tags/')) && 'dunglas/frankenphp' || 'dunglas/frankenphp-dev' }} + GOTOOLCHAIN: local jobs: prepare: runs-on: ubuntu-24.04 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 99749f6d5f..c45d26effc 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,6 +13,8 @@ on: - "docs/**" permissions: contents: read +env: + GOTOOLCHAIN: local jobs: tests-linux: name: Tests (Linux, PHP ${{ matrix.php-versions }}) diff --git a/Dockerfile b/Dockerfile index a1e804153f..1114b82b98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,6 +57,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] COPY --from=golang-base /usr/local/go /usr/local/go ENV PATH=/usr/local/go/bin:$PATH +ENV GOTOOLCHAIN=local # This is required to link the FrankenPHP binary to the PHP binary RUN apt-get update && \ diff --git a/alpine.Dockerfile b/alpine.Dockerfile index 7089ce93a6..a7f3ed618b 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -57,6 +57,7 @@ SHELL ["/bin/ash", "-eo", "pipefail", "-c"] COPY --link --from=golang-base /usr/local/go /usr/local/go ENV PATH=/usr/local/go/bin:$PATH +ENV GOTOOLCHAIN=local # hadolint ignore=SC2086 RUN apk add --no-cache --virtual .build-deps \ diff --git a/caddy/caddy.go b/caddy/caddy.go index 5a54ca8e85..f8169c988d 100644 --- a/caddy/caddy.go +++ b/caddy/caddy.go @@ -343,7 +343,7 @@ func (f *FrankenPHPApp) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { } if f.MaxThreads > 0 && f.NumThreads > 0 && f.MaxThreads < f.NumThreads { - return errors.New("'max_threads' must be greater than or equal to 'num_threads'") + return errors.New(`"max_threads"" must be greater than or equal to "num_threads"`) } return nil diff --git a/caddy/caddy_test.go b/caddy/caddy_test.go index 41a5daa4ef..8d4c9a11d3 100644 --- a/caddy/caddy_test.go +++ b/caddy/caddy_test.go @@ -55,6 +55,37 @@ func TestPHP(t *testing.T) { wg.Wait() } +func TestPHPSimplified(t *testing.T) { + var wg sync.WaitGroup + tester := caddytest.NewTester(t) + tester.InitServer(` + { + skip_install_trust + admin localhost:2999 + http_port `+testPort+` + https_port 9443 + } + + localhost:`+testPort+` { + route { + php { + root ../testdata + } + } + } + `, "caddyfile") + + for i := 0; i < 100; i++ { + wg.Add(1) + + go func(i int) { + tester.AssertGetResponse(fmt.Sprintf("http://localhost:"+testPort+"/index.php?i=%d", i), http.StatusOK, fmt.Sprintf("I am by birth a Genevese (%d)", i)) + wg.Done() + }(i) + } + wg.Wait() +} + func TestLargeRequest(t *testing.T) { tester := caddytest.NewTester(t) tester.InitServer(` diff --git a/dev-alpine.Dockerfile b/dev-alpine.Dockerfile index e5f35f2ec8..d34e41d674 100644 --- a/dev-alpine.Dockerfile +++ b/dev-alpine.Dockerfile @@ -3,6 +3,7 @@ #checkov:skip=CKV_DOCKER_3 FROM golang:1.24-alpine +ENV GOTOOLCHAIN=lcoal ENV CFLAGS="-ggdb3" ENV PHPIZE_DEPS="\ autoconf \ diff --git a/dev.Dockerfile b/dev.Dockerfile index 8a5e7f46d1..3214aad481 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -3,6 +3,7 @@ #checkov:skip=CKV_DOCKER_3 FROM golang:1.24 +ENV GOTOOLCHAIN=lcoal ENV CFLAGS="-ggdb3" ENV PHPIZE_DEPS="\ autoconf \ diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index f7224114d7..b6a1fe7630 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -22,7 +22,8 @@ ARG MIMALLOC='' ARG NO_COMPRESS='' # go version -ENV GO_VERSION=1.24.1 +ENV GO_VERSION=1.24 +ENV GOTOOLCHAIN=local # labels, same as static-builder.Dockerfile LABEL org.opencontainers.image.title=FrankenPHP diff --git a/static-builder-musl.Dockerfile b/static-builder-musl.Dockerfile index 3f7ab48327..6bd0d77bae 100644 --- a/static-builder-musl.Dockerfile +++ b/static-builder-musl.Dockerfile @@ -21,6 +21,8 @@ ARG DEBUG_SYMBOLS='' ARG MIMALLOC='' ARG NO_COMPRESS='' +ENV GOTOOLCHAIN=local + SHELL ["/bin/ash", "-eo", "pipefail", "-c"] LABEL org.opencontainers.image.title=FrankenPHP From f81bc3a4f565cd794a4d72725aa7150ef414888b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 8 May 2025 21:03:52 +0200 Subject: [PATCH 2/9] fix --- static-builder-gnu.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index b6a1fe7630..6c277749b5 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -22,7 +22,7 @@ ARG MIMALLOC='' ARG NO_COMPRESS='' # go version -ENV GO_VERSION=1.24 +ENV GO_VERSION=1.24.2 ENV GOTOOLCHAIN=local # labels, same as static-builder.Dockerfile From 4265d70d8951e663a79f08b239da1afc190f6b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 9 May 2025 01:02:51 +0200 Subject: [PATCH 3/9] Update dev-alpine.Dockerfile Co-authored-by: Alexander Stecher <45872305+AlliBalliBaba@users.noreply.github.com> --- dev-alpine.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-alpine.Dockerfile b/dev-alpine.Dockerfile index d34e41d674..7a95498288 100644 --- a/dev-alpine.Dockerfile +++ b/dev-alpine.Dockerfile @@ -3,7 +3,7 @@ #checkov:skip=CKV_DOCKER_3 FROM golang:1.24-alpine -ENV GOTOOLCHAIN=lcoal +ENV GOTOOLCHAIN=local ENV CFLAGS="-ggdb3" ENV PHPIZE_DEPS="\ autoconf \ From c768d9aea2f8acbbdd2fb3a586f1c3b707c1f9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 9 May 2025 01:03:05 +0200 Subject: [PATCH 4/9] Update dev.Dockerfile Co-authored-by: Alexander Stecher <45872305+AlliBalliBaba@users.noreply.github.com> --- dev.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.Dockerfile b/dev.Dockerfile index 3214aad481..615d01223d 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -3,7 +3,7 @@ #checkov:skip=CKV_DOCKER_3 FROM golang:1.24 -ENV GOTOOLCHAIN=lcoal +ENV GOTOOLCHAIN=local ENV CFLAGS="-ggdb3" ENV PHPIZE_DEPS="\ autoconf \ From e3b4662651a72919e0c7e9a3d8666d0695e6b821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 11 May 2025 07:48:15 +0200 Subject: [PATCH 5/9] fix --- Dockerfile | 4 ++-- alpine.Dockerfile | 2 +- caddy/go.mod | 2 -- go.mod | 2 -- static-builder-gnu.Dockerfile | 6 +++--- static-builder-musl.Dockerfile | 4 ++-- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1114b82b98..33dd61ede7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,11 +94,11 @@ RUN curl -s https://api.github.com/repos/e-dant/watcher/releases/latest | \ WORKDIR /go/src/app COPY --link go.mod go.sum ./ -RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get +RUN go download WORKDIR /go/src/app/caddy COPY --link caddy/go.mod caddy/go.sum ./ -RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get +RUN go mod download WORKDIR /go/src/app COPY --link . ./ diff --git a/alpine.Dockerfile b/alpine.Dockerfile index a7f3ed618b..0aafb87063 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -103,7 +103,7 @@ RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get WORKDIR /go/src/app/caddy COPY caddy/go.mod caddy/go.sum ./ -RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get +RUN go mod download WORKDIR /go/src/app COPY --link . ./ diff --git a/caddy/go.mod b/caddy/go.mod index c902443c5b..a9e7c7f19b 100644 --- a/caddy/go.mod +++ b/caddy/go.mod @@ -2,8 +2,6 @@ module github.com/dunglas/frankenphp/caddy go 1.24.0 -toolchain go1.24.2 - replace github.com/dunglas/frankenphp => ../ retract v1.0.0-rc.1 // Human error diff --git a/go.mod b/go.mod index 41d3c5540f..77bf57cab6 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/dunglas/frankenphp go 1.24 -toolchain go1.24.2 - retract v1.0.0-rc.1 // Human error require ( diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index 6c277749b5..5089ac59ce 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -123,12 +123,12 @@ ENV SPC_REL_TYPE='binary' ENV COMPOSER_ALLOW_SUPERUSER=1 WORKDIR /go/src/app -COPY go.mod go.sum ./ -RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get +COPY go.mod go.sum ./ +RUN go mod download WORKDIR /go/src/app/caddy COPY caddy/go.mod caddy/go.sum ./ -RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get +RUN go mod download WORKDIR /go/src/app COPY --link *.* ./ diff --git a/static-builder-musl.Dockerfile b/static-builder-musl.Dockerfile index 6bd0d77bae..b2e7bb621c 100644 --- a/static-builder-musl.Dockerfile +++ b/static-builder-musl.Dockerfile @@ -83,11 +83,11 @@ COPY --from=composer/composer:2-bin /composer /usr/bin/composer WORKDIR /go/src/app COPY go.mod go.sum ./ -RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get +RUN go mod download WORKDIR /go/src/app/caddy COPY caddy/go.mod caddy/go.sum ./ -RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get +RUN go mod download WORKDIR /go/src/app COPY --link . ./ From 820ffee43ea307cbad6485c90c74d237952205fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 11 May 2025 12:13:15 +0200 Subject: [PATCH 6/9] fix --- static-builder-gnu.Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index 410d7b6a9e..4e92a46e8f 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -23,6 +23,7 @@ ARG NO_COMPRESS='' # go version ENV GOTOOLCHAIN=local +ENV GO_VERSION=1.24.1 # labels, same as static-builder.Dockerfile LABEL org.opencontainers.image.title=FrankenPHP @@ -94,10 +95,9 @@ RUN yum install -y \ else \ GO_ARCH="amd64" ; \ fi ; \ - curl -o jq -fsSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-${GO_ARCH} && \ + curl -o /usr/local/bin/jq -fsSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-${GO_ARCH} && \ chmod +x jq && \ - mv jq /usr/local/bin/jq && \ - curl -LO https://get.golang.org/$(uname)/go_installer && chmod +x go_installer && ./go_installer && rm go_installer && \ + curl -o go.tgz -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && rm -rf /usr/local/go && \ tar -C /usr/local -xzf go.tgz && \ rm go.tgz && \ From bd9bf3b116e96b43b9efe6a62b94fa2a94acef22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 11 May 2025 16:15:49 +0200 Subject: [PATCH 7/9] Update static-builder-gnu.Dockerfile --- static-builder-gnu.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index 08c4b49ea7..5e1a5f94de 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -97,7 +97,7 @@ RUN yum install -y \ fi ; \ curl -o /usr/local/bin/jq -fsSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-${GO_ARCH} && \ chmod +x jq && \ - curl -o go.tgz -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && + curl -o go.tgz -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && \ rm -rf /usr/local/go && \ tar -C /usr/local -xzf go.tgz && \ rm go.tgz && \ @@ -105,7 +105,7 @@ RUN yum install -y \ ENV PATH="/cmake/bin:/usr/local/go/bin:$PATH" -# Apply gnu mode +# Apply GNU mode ENV CC='/opt/rh/devtoolset-10/root/usr/bin/gcc' ENV CXX='/opt/rh/devtoolset-10/root/usr/bin/g++' ENV AR='/opt/rh/devtoolset-10/root/usr/bin/ar' From 643a6c92e890b567b2bc56a6e915b0e5d0f499cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 11 May 2025 17:28:27 +0200 Subject: [PATCH 8/9] Update static-builder-gnu.Dockerfile --- static-builder-gnu.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index 5e1a5f94de..1330ad4ba0 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -23,7 +23,7 @@ ARG NO_COMPRESS='' # go version ENV GOTOOLCHAIN=local -ENV GO_VERSION=1.24.1 +ENV GO_VERSION=1.24.3 # labels, same as static-builder.Dockerfile LABEL org.opencontainers.image.title=FrankenPHP From 5b4ad9be3354417ede02bee3148f681a84068fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 11 May 2025 17:34:18 +0200 Subject: [PATCH 9/9] Update static-builder-gnu.Dockerfile --- static-builder-gnu.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index 1330ad4ba0..7fa40d5cec 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -96,7 +96,7 @@ RUN yum install -y \ GO_ARCH="amd64" ; \ fi ; \ curl -o /usr/local/bin/jq -fsSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-${GO_ARCH} && \ - chmod +x jq && \ + chmod +x /usr/local/bin/jq && \ curl -o go.tgz -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && \ rm -rf /usr/local/go && \ tar -C /usr/local -xzf go.tgz && \