From 1584ec3262fd3b2edb82b16470b31506223e0819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 14 Dec 2023 14:54:24 +0100 Subject: [PATCH 1/3] docs: xcaddy build flags --- docs/compile.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/compile.md b/docs/compile.md index 53cf02274..fb8f1707b 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -83,10 +83,22 @@ CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-c Alternatively, use [xcaddy](https://github.com/caddyserver/xcaddy) to compile FrankenPHP with [custom Caddy modules](https://caddyserver.com/docs/modules/): ```console -CGO_ENABLED=1 xcaddy build \ +CGO_ENABLED=1 \ +XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'" \ +xcaddy build \ --output frankenphp \ --with github.com/dunglas/frankenphp/caddy \ --with github.com/dunglas/mercure/caddy \ --with github.com/dunglas/vulcain/caddy # Add extra Caddy modules here ``` + +> [!TIP] +> +> If you're using musl libc (the default on Alpine Linux) and Symfony, +> you may need to increase the default stack size. +> Otherwise, you may get errors like `PHP Fatal error: Maximum call stack size of 83360 bytes reached during compilation. Try splitting expression` +> +> To do so, change the `XCADDY_GO_BUILD_FLAGS` environment variable to something like +> `XCADDY_GO_BUILD_FLAGS=$'-ldflags "-w -s -extldflags \'-Wl,-z,stack-size=0x80000\'"'` +> (change the value of the stack size according to your app needs). \ No newline at end of file From 8a6f6345900047a27634b3d189d0dd8a4b664400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 14 Dec 2023 15:02:29 +0100 Subject: [PATCH 2/3] docker --- docs/docker.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/docker.md b/docs/docker.md index f91d07d29..fb9d6f304 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -51,7 +51,7 @@ FROM dunglas/frankenphp:latest-builder AS builder COPY --from=caddy:builder /usr/bin/xcaddy /usr/bin/xcaddy # CGO must be enabled to build FrankenPHP -ENV CGO_ENABLED=1 XCADDY_SETCAP=1 +ENV CGO_ENABLED=1 XCADDY_SETCAP=1 XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'" RUN xcaddy build \ --output /usr/local/bin/frankenphp \ --with github.com/dunglas/frankenphp=./ \ @@ -70,6 +70,11 @@ COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp The `builder` image provided by FrankenPHP contains a compiled version of libphp. [Builders images](https://hub.docker.com/r/dunglas/frankenphp/tags?name=builder) are provided for all versions of FrankenPHP and PHP, both for Alpine and Debian. +> [!TIP] +> +> If you're using Alpine Linux and Symfony, +> you may need to [increase the default stack size](compile.md#using-xcaddy). + ## Enabling the Worker Mode by Default Set the `FRANKENPHP_CONFIG` environment variable to start FrankenPHP with a worker script: From 15c7b2f92b90f8ca3047f08e120e7ee58026735a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 14 Dec 2023 21:55:25 +0100 Subject: [PATCH 3/3] linter --- docs/compile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compile.md b/docs/compile.md index fb8f1707b..380051b30 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -101,4 +101,4 @@ xcaddy build \ > > To do so, change the `XCADDY_GO_BUILD_FLAGS` environment variable to something like > `XCADDY_GO_BUILD_FLAGS=$'-ldflags "-w -s -extldflags \'-Wl,-z,stack-size=0x80000\'"'` -> (change the value of the stack size according to your app needs). \ No newline at end of file +> (change the value of the stack size according to your app needs).