Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbae6b5798 |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# caddy
|
||||
|
||||
Copier template for a `caddy/` directory: a portable `site.caddy` for the project's `api` and `frontend` services, a standalone Caddy compose file and an example global Caddyfile.
|
||||
Copier template for a `caddy/` directory: a portable `site.caddy` for the project's `api` and `frontend`, a standalone compose file and an example Caddyfile.
|
||||
|
||||
```sh
|
||||
copier copy --trust -d project_slug=my_thing -d 'routes=["api","frontend"]' <this-repo> <dest>
|
||||
|
||||
@@ -1,23 +1,5 @@
|
||||
{%- set dash = project_slug | replace('_', '-') -%}
|
||||
{%- set domain = project_slug | upper | replace('-', '_') ~ '_DOMAIN' -%}
|
||||
# caddy
|
||||
|
||||
`site.caddy` routes `{{ '{$' }}{{ project_slug | upper | replace('-', '_') }}_DOMAIN}` to the project's services over the external `caddy` docker network. It works standalone and inside a shared Caddy that fronts several projects.
|
||||
|
||||
Standalone:
|
||||
|
||||
```sh
|
||||
docker network create caddy
|
||||
cp Caddyfile.example Caddyfile
|
||||
cp .env.example .env
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Shared Caddy: mount this directory as `/etc/caddy/projects.d/{{ dash }}:ro`, keep `import /etc/caddy/projects.d/*/site.caddy` in its Caddyfile and put `{{ project_slug | upper | replace('-', '_') }}_DOMAIN` in its environment.
|
||||
|
||||
Rules that keep `site.caddy` portable:
|
||||
|
||||
- the domain comes only from the environment variable
|
||||
- no `tls` block, certificates are configured by the host Caddy (`acme_dns cloudflare {env.CLOUDFLARE_API_TOKEN}` in the global block)
|
||||
- snippets are prefixed with the project slug because Caddy snippets are global
|
||||
- mount the directory, not the file: a single-file bind mount goes stale when git replaces the inode
|
||||
- keep `admin localhost:2019`, `admin off` makes `caddy reload` impossible
|
||||
`site.caddy` routes `{{ '{$' }}{{ domain }}}` to the project over the external `caddy` network. In a shared Caddy, mount this directory as `/etc/caddy/projects.d/{{ dash }}:ro` and set `{{ domain }}`. Keep it portable: domain only from the env, no `tls`, snippets prefixed with `{{ project_slug }}_`.
|
||||
Reference in new issue
Block a user