Skip to content

Commit 9d56f25

Browse files
committed
docs: add custom Caddy modules
1 parent 4d2cd5f commit 9d56f25

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

docs/compile.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ make -j$(sysctl -n hw.logicalcpu)
6868
sudo make install
6969
```
7070

71-
#### Compile the Go App
71+
## Compile the Go App
7272

7373
You can now use the Go library and compile our Caddy build:
7474

@@ -77,3 +77,16 @@ curl -L https://github.com/dunglas/frankenphp/archive/refs/heads/main.tar.gz | t
7777
cd frankenphp-main/caddy/frankenphp
7878
CGO_CFLAGS=$(php-config --includes) go build
7979
```
80+
81+
### Using xcaddy
82+
83+
Alternatively, use [xcaddy](https://github.com/caddyserver/xcaddy) to compile FrankenPHP with [custom Caddy modules](https://caddyserver.com/docs/modules/):
84+
85+
```console
86+
CGO_ENABLED=1 xcaddy build \
87+
--output frankenphp \
88+
--with github.com/dunglas/frankenphp/caddy \
89+
--with github.com/dunglas/mercure/caddy \
90+
--with github.com/dunglas/vulcain/caddy
91+
# Add extra Caddy modules here
92+
```

docs/docker.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,38 @@ RUN install-php-extensions \
3838
# ...
3939
```
4040

41+
## How to Install More Caddy Modules
42+
43+
FrankenPHP is built on top of Caddy, and all [Caddy modules](https://caddyserver.com/docs/modules/) can be used with FrankenPHP.
44+
45+
The easiest way to install custom Caddy modules is to use [xcaddy](https://github.com/caddyserver/xcaddy):
46+
47+
```dockerfile
48+
FROM dunglas/frankenphp:latest-builder AS builder
49+
50+
# Copy xcaddy in the builder image
51+
COPY --from=caddy:builder /usr/bin/xcaddy /usr/bin/xcaddy
52+
53+
# CGO must be enabled to build FrankenPHP
54+
ENV CGO_ENABLED=1 XCADDY_SETCAP=1
55+
RUN xcaddy build \
56+
--output /usr/local/bin/frankenphp \
57+
--with github.com/dunglas/frankenphp=./ \
58+
--with github.com/dunglas/frankenphp/caddy=./caddy/ \
59+
# Mercure and Vulcain are included in the official build, but feel free to remove them
60+
--with github.com/dunglas/mercure/caddy \
61+
--with github.com/dunglas/vulcain/caddy
62+
# Add extra Caddy modules here
63+
64+
FROM dunglas/frankenphp AS runner
65+
66+
# Replace the official binary by the one contained your custom modules
67+
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
68+
```
69+
70+
The `builder` image provided by FrankenPHP contains a compiled version of libphp.
71+
[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.
72+
4173
# Enabling the Worker Mode by Default
4274

4375
Set the `FRANKENPHP_CONFIG` environment variable to start FrankenPHP with a worker script:

0 commit comments

Comments
 (0)