Skip to content

Commit dcfdb2f

Browse files
docs: hardened image with Caddy environment vars (#2229)
Adds `XDG_CONFIG_HOME` and `XDG_DATA_HOME` to the example hardened image docs, otherwise Caddy will fail to use the nonexistent /home directory instead of `/data/caddy` and `/config/caddy`. Also removes an unnecessary `--chown=nonroot:nonroot`.
1 parent 8f4412c commit dcfdb2f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/docker.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,16 @@ COPY "$PATH_TO_CADDYFILE" /etc/caddy/Caddyfile
256256
257257
# Copy frankenphp and necessary libs
258258
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
259-
COPY --from=builder --chown=nonroot:nonroot /usr/local/lib/php/extensions /usr/local/lib/php/extensions
259+
COPY --from=builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions
260260
COPY --from=builder /tmp/libs /usr/lib
261261
262262
# Copy php.ini configuration files
263263
COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
264264
COPY --from=builder /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
265265
266-
# Create necessary caddy dirs
267-
# These dirs also need to be writable in case of a read-only root filesystem
266+
# Caddy data dirs — must be writable for nonroot, even on a read-only root filesystem
267+
ENV XDG_CONFIG_HOME=/config \
268+
XDG_DATA_HOME=/data
268269
COPY --from=builder --chown=nonroot:nonroot /data/caddy /data/caddy
269270
COPY --from=builder --chown=nonroot:nonroot /config/caddy /config/caddy
270271

0 commit comments

Comments
 (0)