From 5dd7111a4a7439dc1bb7a27d50a9c51ee8e8987f Mon Sep 17 00:00:00 2001 From: Bjoern Ludwig Date: Sat, 24 Aug 2024 12:10:29 +0200 Subject: [PATCH 01/10] Update docs for Caddy image with a fix to its reload feature --- caddy/content.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/caddy/content.md b/caddy/content.md index 7999442e934a..53563e6791fe 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -35,15 +35,19 @@ $ curl http://localhost/ hello world ``` -To override the default [`Caddyfile`](https://github.com/caddyserver/dist/blob/master/config/Caddyfile), you can mount a new one at `/etc/caddy/Caddyfile`: +To override the default [`Caddyfile`](https://github.com/caddyserver/dist/blob/master/config/Caddyfile), you can create one in the subfolder `caddyfile` at `$PWD/caddyfile/Caddyfile` and mount this folder at `/etc/caddy`: ```console $ docker run -d -p 80:80 \ - -v $PWD/Caddyfile:/etc/caddy/Caddyfile \ + -v $PWD/caddyfile:/etc/caddy \ -v caddy_data:/data \ %%IMAGE%% ``` +#### ⚠️ Do not mount the Caddyfile directly at `/etc/caddy/Caddyfile` + +This effectively disables Caddy's graceful reload feature in many cases depending on the way you apply changes to the file as discussed in [this issue](https://github.com/caddyserver/caddy/issues/5735#issuecomment-1675896585). + ### Automatic TLS with the Caddy image The default `Caddyfile` only listens to port `80`, and does not set up automatic TLS. However, if you have a domain name for your site, and its A/AAAA DNS records are properly pointed to this machine's public IP, then you can use this command to simply serve a site over HTTPS: @@ -119,11 +123,9 @@ See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for more details. ### Docker Compose example -If you prefer to use `docker-compose` to run your stack, here's a sample service definition. +If you prefer to use `docker-compose` to run your stack, here's a sample service definition which goes into your `compose.yaml`. ```yaml -version: "3.7" - services: caddy: image: %%IMAGE%%: @@ -135,7 +137,7 @@ services: - "443:443" - "443:443/udp" volumes: - - $PWD/Caddyfile:/etc/caddy/Caddyfile + - $PWD/caddyfile:/etc/caddy - $PWD/site:/srv - caddy_data:/data - caddy_config:/config @@ -147,3 +149,5 @@ volumes: ``` Defining the data volume as [`external`](https://docs.docker.com/compose/compose-file/compose-file-v3/#external) makes sure `docker-compose down` does not delete the volume. You may need to create it manually using `docker volume create [project-name]_caddy_data`. + +Graceful reloads can then be conducted via `docker compose exec --workdir /etc/caddy caddy caddy reload`. From 0809d9e4de45f81a4270f8e162911c608efe85c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ludwig?= Date: Wed, 28 Aug 2024 22:39:24 +0200 Subject: [PATCH 02/10] Update caddy/content.md to be potentially less confusing Co-authored-by: Francis Lavoie --- caddy/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/content.md b/caddy/content.md index 53563e6791fe..e3208c7ad0f2 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -35,7 +35,7 @@ $ curl http://localhost/ hello world ``` -To override the default [`Caddyfile`](https://github.com/caddyserver/dist/blob/master/config/Caddyfile), you can create one in the subfolder `caddyfile` at `$PWD/caddyfile/Caddyfile` and mount this folder at `/etc/caddy`: +To override the default [`Caddyfile`](https://github.com/caddyserver/dist/blob/master/config/Caddyfile), you can create one in the subfolder `conf` at `$PWD/conf/Caddyfile` and mount this folder at `/etc/caddy`: ```console $ docker run -d -p 80:80 \ From d860ee48888af5dd6705745d15fa2259f5fe5f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ludwig?= Date: Wed, 28 Aug 2024 22:41:39 +0200 Subject: [PATCH 03/10] Update caddy/content.md to be potentially less confusing Co-authored-by: Francis Lavoie --- caddy/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/content.md b/caddy/content.md index e3208c7ad0f2..b7eb657e2af1 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -39,7 +39,7 @@ To override the default [`Caddyfile`](https://github.com/caddyserver/dist/blob/m ```console $ docker run -d -p 80:80 \ - -v $PWD/caddyfile:/etc/caddy \ + -v $PWD/conf:/etc/caddy \ -v caddy_data:/data \ %%IMAGE%% ``` From a750af6377f2e4b206e62121fa0a2d78b9d616fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ludwig?= Date: Wed, 28 Aug 2024 22:45:18 +0200 Subject: [PATCH 04/10] Update caddy/content.md with better wording Co-authored-by: Francis Lavoie --- caddy/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/content.md b/caddy/content.md index b7eb657e2af1..164cad64ff1c 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -123,7 +123,7 @@ See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for more details. ### Docker Compose example -If you prefer to use `docker-compose` to run your stack, here's a sample service definition which goes into your `compose.yaml`. +If you prefer to use `docker compose` to run your stack, here's a sample service definition which goes in a file named `compose.yaml`. ```yaml services: From 61797fd33dd90f2b70d53b267b764107eb4f2c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ludwig?= Date: Wed, 28 Aug 2024 22:54:53 +0200 Subject: [PATCH 05/10] Update caddy/content.md with short flag for docker compose reload command Co-authored-by: Francis Lavoie --- caddy/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/content.md b/caddy/content.md index 164cad64ff1c..a9b9d6cce913 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -150,4 +150,4 @@ volumes: Defining the data volume as [`external`](https://docs.docker.com/compose/compose-file/compose-file-v3/#external) makes sure `docker-compose down` does not delete the volume. You may need to create it manually using `docker volume create [project-name]_caddy_data`. -Graceful reloads can then be conducted via `docker compose exec --workdir /etc/caddy caddy caddy reload`. +Graceful reloads can then be conducted via `docker compose exec -w /etc/caddy caddy caddy reload`. From c7983398103b21a9cf33aee9a5440461b2ffaf05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ludwig?= Date: Wed, 28 Aug 2024 22:57:16 +0200 Subject: [PATCH 06/10] Update caddy/content.md to get rid of trailing whitespace --- caddy/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/content.md b/caddy/content.md index a9b9d6cce913..7708ac2c58a1 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -123,7 +123,7 @@ See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for more details. ### Docker Compose example -If you prefer to use `docker compose` to run your stack, here's a sample service definition which goes in a file named `compose.yaml`. +If you prefer to use `docker compose` to run your stack, here's a sample service definition which goes in a file named `compose.yaml`. ```yaml services: From c64b526909defb13ef02bdc23a3d9e0862446960 Mon Sep 17 00:00:00 2001 From: Bjoern Ludwig Date: Sat, 19 Oct 2024 18:34:42 +0200 Subject: [PATCH 07/10] Update caddy/content.md with one more change completing the intended change from commit d860ee48 --- caddy/content.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/caddy/content.md b/caddy/content.md index 7708ac2c58a1..c3560e7f301c 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -123,7 +123,7 @@ See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for more details. ### Docker Compose example -If you prefer to use `docker compose` to run your stack, here's a sample service definition which goes in a file named `compose.yaml`. +If you prefer to use `docker compose` to run your stack, here's a sample service definition which goes in a file named `compose.yaml`. The configuration assumes you put a custom Caddyfile into `$PWD/conf` as described [above](#basic-usage). ```yaml services: @@ -137,7 +137,7 @@ services: - "443:443" - "443:443/udp" volumes: - - $PWD/caddyfile:/etc/caddy + - $PWD/conf:/etc/caddy - $PWD/site:/srv - caddy_data:/data - caddy_config:/config From d0add51124106eb75429bd8cb6f3c0d26a15f025 Mon Sep 17 00:00:00 2001 From: Bjoern Ludwig Date: Sat, 19 Oct 2024 18:38:37 +0200 Subject: [PATCH 08/10] Update caddy/content.md with improved wording --- caddy/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/content.md b/caddy/content.md index c3560e7f301c..423526b71820 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -46,7 +46,7 @@ $ docker run -d -p 80:80 \ #### ⚠️ Do not mount the Caddyfile directly at `/etc/caddy/Caddyfile` -This effectively disables Caddy's graceful reload feature in many cases depending on the way you apply changes to the file as discussed in [this issue](https://github.com/caddyserver/caddy/issues/5735#issuecomment-1675896585). +If vim or another editor is used that changes the inode of the edited file, the changes will only be applied within the container when the container is recreated , which is explained in detail in this [Medium article](https://medium.com/@jonsbun/why-need-to-be-careful-when-mounting-single-files-into-a-docker-container-4f929340834). When using such an editor, Caddy's graceful reload functionality might not work as expected, as described in [this issue](https://github.com/caddyserver/caddy/issues/5735#issuecomment-1675896585). ### Automatic TLS with the Caddy image From cfe84c257eb78cab73772e797339016e9ab0fd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ludwig?= Date: Fri, 22 Nov 2024 09:57:13 +0100 Subject: [PATCH 09/10] Update caddy/content.md to fix typo Co-authored-by: Francis Lavoie --- caddy/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caddy/content.md b/caddy/content.md index 423526b71820..4f6fc0de651e 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -46,7 +46,7 @@ $ docker run -d -p 80:80 \ #### ⚠️ Do not mount the Caddyfile directly at `/etc/caddy/Caddyfile` -If vim or another editor is used that changes the inode of the edited file, the changes will only be applied within the container when the container is recreated , which is explained in detail in this [Medium article](https://medium.com/@jonsbun/why-need-to-be-careful-when-mounting-single-files-into-a-docker-container-4f929340834). When using such an editor, Caddy's graceful reload functionality might not work as expected, as described in [this issue](https://github.com/caddyserver/caddy/issues/5735#issuecomment-1675896585). +If vim or another editor is used that changes the inode of the edited file, the changes will only be applied within the container when the container is recreated, which is explained in detail in this [Medium article](https://medium.com/@jonsbun/why-need-to-be-careful-when-mounting-single-files-into-a-docker-container-4f929340834). When using such an editor, Caddy's graceful reload functionality might not work as expected, as described in [this issue](https://github.com/caddyserver/caddy/issues/5735#issuecomment-1675896585). ### Automatic TLS with the Caddy image From d6d9b3b88dfe27b1ee775ce3d0b5f0f91ef427a1 Mon Sep 17 00:00:00 2001 From: Bjoern Ludwig Date: Fri, 22 Nov 2024 11:20:53 +0100 Subject: [PATCH 10/10] Update caddy/content.md with simplification of persisting data volume --- caddy/content.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/caddy/content.md b/caddy/content.md index 4f6fc0de651e..e38e50c87b7f 100644 --- a/caddy/content.md +++ b/caddy/content.md @@ -144,10 +144,7 @@ services: volumes: caddy_data: - external: true caddy_config: ``` -Defining the data volume as [`external`](https://docs.docker.com/compose/compose-file/compose-file-v3/#external) makes sure `docker-compose down` does not delete the volume. You may need to create it manually using `docker volume create [project-name]_caddy_data`. - Graceful reloads can then be conducted via `docker compose exec -w /etc/caddy caddy caddy reload`.