Create docker-compose.prod.yml with Caddy reverse proxy and TLS #136
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The current
docker-compose.ymlis designed for local development:8080, frontend on5173).A production VPS needs a reverse proxy (Caddy) sitting in front of both services, handling TLS termination, routing, and security headers. Caddy is the right choice here: automatic Let's Encrypt TLS with zero configuration, simple
Caddyfilesyntax, and it runs as a Docker service alongside the app.What to do
1. Create
CaddyfileReplace
familienarchiv.example.comwith the actual domain. Caddy will automatically obtain and renew a Let's Encrypt certificate for it.2. Create
docker-compose.prod.ymlThis file is applied on top of
docker-compose.ymlusing Docker Compose's overlay pattern (-f docker-compose.yml -f docker-compose.prod.yml). It only overrides what needs to change for production.3. Deployment command
4. DNS prerequisite
The domain must have an A record pointing to the VPS IP before starting Caddy, otherwise the Let's Encrypt HTTP-01 challenge will fail and Caddy will not start with TLS.
What this gives us
Acceptance criteria
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -dstarts onlydb,backend,frontend,caddy.https://familienarchiv.example.comserves the SvelteKit app with a valid TLS certificate.https://familienarchiv.example.com/api/actuator/healthreturns{"status":"UP"}.http://familienarchiv.example.comredirects tohttps://.8080and3000are not directly accessible from outside the Docker network.