From b2435183f4bda230db6cd60f2bc419bd51f3171c Mon Sep 17 00:00:00 2001 From: Alexandre Daubois <2144837+alexandre-daubois@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:47:58 +0200 Subject: [PATCH] feat: add support for `SERVER_ROOT` to provide a different app root (#1678) --- caddy/frankenphp/Caddyfile | 2 +- docs/config.md | 1 + docs/fr/config.md | 1 + docs/fr/production.md | 3 +++ docs/production.md | 3 +++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/caddy/frankenphp/Caddyfile b/caddy/frankenphp/Caddyfile index c73181af..1a35e7ef 100644 --- a/caddy/frankenphp/Caddyfile +++ b/caddy/frankenphp/Caddyfile @@ -25,7 +25,7 @@ # } #} - root public/ + root {$SERVER_ROOT:public/} encode zstd br gzip # Uncomment the following lines to enable Mercure and Vulcain modules diff --git a/docs/config.md b/docs/config.md index ab047500..4bf8c989 100644 --- a/docs/config.md +++ b/docs/config.md @@ -236,6 +236,7 @@ You can find more information about this setting in the [Caddy documentation](ht The following environment variables can be used to inject Caddy directives in the `Caddyfile` without modifying it: - `SERVER_NAME`: change [the addresses on which to listen](https://caddyserver.com/docs/caddyfile/concepts#addresses), the provided hostnames will also be used for the generated TLS certificate +- `SERVER_ROOT`: change the root directory of the site, defaults to `public/` - `CADDY_GLOBAL_OPTIONS`: inject [global options](https://caddyserver.com/docs/caddyfile/options) - `FRANKENPHP_CONFIG`: inject config under the `frankenphp` directive diff --git a/docs/fr/config.md b/docs/fr/config.md index beb97338..50435bdd 100644 --- a/docs/fr/config.md +++ b/docs/fr/config.md @@ -235,6 +235,7 @@ Vous trouverez plus d'informations sur ce paramètre dans la [documentation Cadd Les variables d'environnement suivantes peuvent être utilisées pour insérer des directives Caddy dans le `Caddyfile` sans le modifier : - `SERVER_NAME` : change [les adresses sur lesquelles écouter](https://caddyserver.com/docs/caddyfile/concepts#addresses), les noms d'hôte fournis seront également utilisés pour le certificat TLS généré +- `SERVER_ROOT` : change le répertoire racine du site, par défaut `public/` - `CADDY_GLOBAL_OPTIONS` : injecte [des options globales](https://caddyserver.com/docs/caddyfile/options) - `FRANKENPHP_CONFIG` : insère la configuration sous la directive `frankenphp` diff --git a/docs/fr/production.md b/docs/fr/production.md index 8901f885..7e1606c5 100644 --- a/docs/fr/production.md +++ b/docs/fr/production.md @@ -18,6 +18,9 @@ ENV SERVER_NAME=your-domain-name.example.com # Si vous souhaitez désactiver HTTPS, utilisez cette valeur à la place : #ENV SERVER_NAME=:80 +# Si votre projet n'utilise pas le répertoire "public" comme racine web, vous pouvez le définir ici : +# ENV SERVER_ROOT=web/ + # Activer les paramètres de production de PHP RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" diff --git a/docs/production.md b/docs/production.md index 5ad3e2ad..95474f8c 100644 --- a/docs/production.md +++ b/docs/production.md @@ -18,6 +18,9 @@ ENV SERVER_NAME=your-domain-name.example.com # If you want to disable HTTPS, use this value instead: #ENV SERVER_NAME=:80 +# If your project is not using the "public" directory as the web root, you can set it here: +# ENV SERVER_ROOT=web/ + # Enable PHP production settings RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"