- Dockerfile 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .env.example | ||
| .gitignore | ||
| .rsync-exclude | ||
| Caddyfile | ||
| docker-compose.yml | ||
| Dockerfile | ||
| README.md | ||
Insoulum Edge
The border router for *.insoulum.ru: one Caddy container that owns ports
80/443, terminates TLS and routes every request to the right place.
It exists so that projects can stay dumb. Insoulum-Web serves files from disk,
Lucario-Forge serves a port — neither of them knows that Caddy exists, and
neither has to be edited when a new project appears. All routing lives here.
Structure
.
├── Caddyfile ← every site and backend, the only routing map
├── docker-compose.yml ← ports 80/443 + the edge_default network
├── Dockerfile ← Caddy + caddy-dns/desec (DNS-01 for wildcards)
├── .env.example ← DESEC_TOKEN, SITES_DIR
└── data/ ← certificates (created at runtime, gitignored)
This repo is the only thing that owns ports 80/443. Static content lives in
Insoulum-Web and is mounted
read-only; backends like
Lucario-Forge join
edge_default and get a reverse_proxy block.
How routing works
Three rules, in order of specificity:
| Rule | Handles |
|---|---|
insoulum.ru |
the apex — a wildcard cert does not cover it (RFC 6125) |
git.insoulum.ru |
a backend: reverse_proxy forgejo:3000 |
*.insoulum.ru |
everything else: static files from /srv/{host} |
Static sites need no block at all — the wildcard maps {host} to
/srv/{host} and serves it. Add an explicit block only when a site needs
something special (a redirect, custom headers, a rewrite); Caddy prefers the
more specific match.
New backends get a block that names a container and a port:
myapp.insoulum.ru {
import security-headers
reverse_proxy myapp:8080
import tls-desec
}
The project itself just has to join edge_default as an external network:
networks:
edge_default:
external: true
name: edge_default
Startup order
Edge is the only container that touches the internet, so it goes first:
cd /opt/insoulum-edge && docker compose up -d # 1. router, owns edge_default
cd /opt/forgejo && docker compose up -d # 2. backends, optional
Backends declare edge_default as external, so they refuse to start if the
router has never been up. After that, order does not matter — they find each
other by container name.
If git.insoulum.ru shows 502, the router is fine but Forgejo is not
running. Everything else keeps working.
TLS
- Wildcard
*.insoulum.ruand the apex are issued via DNS-01 through the deSEC plugin — no public port 80 needed for validation. - Important: deSEC's
ns2.desec.orgsyncs in ~70s (ns1 — ~3s), and Let's Encrypt checks both nameservers. That's whypropagation_delayis180s— without it issuance fails withNo TXT record found. - Certificates live in
data/(bind-mount) and renew automatically. Copydata/over during a migration to avoid re-issuing.
Deploy
The image is built locally — xcaddy compiles Go, which is an OOM risk on
a 1 GB VDS.
First deploy (fresh server)
# Locally: build and pack
docker build -t insoulum-edge:1.0 .
docker save insoulum-edge:1.0 | gzip > insoulum-edge.tar.gz
# Ship
scp insoulum-edge.tar.gz <host>:/opt/insoulum-edge/
rsync -av --exclude-from='.rsync-exclude' ./ <host>:/opt/insoulum-edge/
# On the server
cd /opt/insoulum-edge
gunzip -c insoulum-edge.tar.gz | docker load
cp .env.example .env && vim .env # DESEC_TOKEN, SITES_DIR
chmod 600 .env
docker compose up -d
After up, Caddy requests the certificates. First issuance takes ~3–4 minutes.
Watch it:
docker logs -f insoulum-edge # wait for "certificate obtained successfully"
Updating
| Changed | Command |
|---|---|
Caddyfile |
rsync + docker compose restart |
docker-compose.yml (ports, networks) |
rsync + docker compose up -d --force-recreate |
| image (new Caddy version) | rebuild locally, ship, docker load, up -d --force-recreate |
docker compose restartdoes not re-readdocker-compose.yml— it reuses the running container's config. Use--force-recreateafter editing env.
Adding a subdomain
- Static site — create
sites/<sub>.insoulum.ru/index.htmlinInsoulum-Web, add a DNS A-record. Nothing to do here. - Backend — add a site block above, make the project join
edge_default, add a DNS A-record, thenrsync+restart.
Consumers
| Project | Role |
|---|---|
Insoulum-Web |
static sites in sites/, mounted here read-only |
Lucario-Forge |
Forgejo, joined to edge_default, served at git.insoulum.ru |
Notes
SITES_DIRis the one knob that points outside this repo. On the server it is/opt/insoulum/sites; locally it defaults to./sites.- The
Serverheader is hidden, security headers are attached to every response — see thesecurity-headerssnippet. edge_defaulthas a fixed name on purpose: consumers declare it as external and would break if it were renamed with the project.