Skip to content

docs: fix Mercure support with Docker hardened images#2270

Open
dunglas wants to merge 1 commit intomainfrom
fix/mercure-hardened
Open

docs: fix Mercure support with Docker hardened images#2270
dunglas wants to merge 1 commit intomainfrom
fix/mercure-hardened

Conversation

@dunglas
Copy link
Member

@dunglas dunglas commented Mar 11, 2026

Prevents errors like this one when using Mercure: php-1 | Error: loading initial config: loading new config: loading frankenphp app module: provision frankenphp: failed to provision caddy http: loading http app module: provision http: server srv0: setting up route handlers: route 2: loading handler modules: position 2: loading module 'mercure': provision http.handlers.mercure: provision http.handlers.mercure.bolt: "": invalid transport: open /data/caddy/mercure.db: permission denied

Copilot AI review requested due to automatic review settings March 11, 2026 16:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the hardened/distroless Dockerfile example in the Docker documentation to copy Caddy’s writable directories differently, aiming to ensure the Caddy state/config paths are present and owned correctly when running as nonroot.

Changes:

  • Adjusts the distroless example to COPY /data and /config from the builder stage (instead of only /data/caddy and /config/caddy).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 266 to +270
# Caddy data dirs — must be writable for nonroot, even on a read-only root filesystem
ENV XDG_CONFIG_HOME=/config \
XDG_DATA_HOME=/data
COPY --from=builder --chown=nonroot:nonroot /data/caddy /data/caddy
COPY --from=builder --chown=nonroot:nonroot /config/caddy /config/caddy
COPY --from=builder --chown=nonroot:nonroot /data /data
COPY --from=builder --chown=nonroot:nonroot /config /config
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this doc, other Dockerfile examples (e.g., the rootless ones above) refer specifically to /config/caddy and /data/caddy. Switching this hardened/distroless example to COPY ... /config and COPY ... /data is less precise and may confuse readers about which paths Caddy actually uses (it still stores state under $XDG_{CONFIG,DATA}_HOME/caddy). Consider reverting to copying only the caddy subdirectories, or update the surrounding comment text to explain why the entire base dirs are copied here (e.g., to ensure /config and /data themselves are owned by nonroot).

Copilot uses AI. Check for mistakes.
@henderkes
Copy link
Contributor

I don't understand how this fixes the error. Does the nonroot user not have execute permissions on /data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants