From 515663ba1cdd5c4d805fa942a12d5f533e12af9e Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 3 Nov 2026 17:36:37 +0000 Subject: [PATCH] docs: add secure dashboard Docker deployment examples - Document Caddy and Cloudflare Tunnel ingress configurations - Explain private networking, HTTPS, and dashboard access protection --- clients/dashboard/README.md | 8 ++ docker/examples/Caddyfile | 6 ++ docker/examples/README.md | 104 +++++++++++++++++++++++ docker/examples/compose.caddy.yaml | 19 +++++ docker/examples/compose.cloudflared.yaml | 9 ++ docker/examples/compose.yaml | 28 ++++++ docs/releases.md | 4 + 7 files changed, 178 insertions(+) create mode 100644 docker/examples/Caddyfile create mode 100644 docker/examples/README.md create mode 100644 docker/examples/compose.caddy.yaml create mode 100644 docker/examples/compose.cloudflared.yaml create mode 100644 docker/examples/compose.yaml diff --git a/clients/dashboard/README.md b/clients/dashboard/README.md index 61623c6..824b76e 100644 --- a/clients/dashboard/README.md +++ b/clients/dashboard/README.md @@ -43,6 +43,14 @@ the actual compiled native/WASM SDKs; no database or bucket is required. Ports external platform-specific dependency. Build it for the target OS/architecture. Do not run the standalone production server with Bun. +## Docker deployment + +Core and the dashboard serve HTTP only; built-in TLS is not currently planned, +though it could be added later. Put them behind cloudflared or an HTTPS reverse +proxy with access control. **Do not expose the dashboard directly to the internet +on port 80.** See the [Docker Compose examples](../../docker/examples/README.md) +for internal networking, Caddy and Cloudflare Tunnel. + ## Behavior and constraints - SSR falls back to localized error states after five seconds without a core diff --git a/docker/examples/Caddyfile b/docker/examples/Caddyfile new file mode 100644 index 0000000..5ded439 --- /dev/null +++ b/docker/examples/Caddyfile @@ -0,0 +1,6 @@ +{$DASHBOARD_HOST} { + basic_auth { + admin {$DASHBOARD_PASSWORD_HASH} + } + reverse_proxy dashboard:4321 +} diff --git a/docker/examples/README.md b/docker/examples/README.md new file mode 100644 index 0000000..970c2f9 --- /dev/null +++ b/docker/examples/README.md @@ -0,0 +1,104 @@ +# Dashboard behind a proxy + +Condite core and the dashboard currently serve **plain HTTP only**. Built-in TLS +is not currently planned, though it could be added eventually. For deployments +in 2026, put Condite behind cloudflared or a reverse proxy that handles HTTPS. +**Exposing the dashboard directly to the internet on port 80 is a horrible idea:** +traffic is unencrypted, and every visitor can use the dashboard's configured API +key. HTTPS alone does not restrict who can use that key; protect the dashboard +with authentication or trusted private access. + +These examples publish no core or dashboard ports. Docker DNS connects the +proxy to `dashboard:4321`, and the dashboard's server-side API proxy connects to +`core:8080` on an `internal: true` network. Only core and the ingress container +also join an outbound-capable network. Do not combine these files with +[`../compose.yaml`](../compose.yaml), which publishes development ports. + +The request path is browser → HTTPS ingress → HTTP dashboard → HTTP core. +File uploads/downloads still go directly between the browser and S3 using signed +URLs. Keep browser-facing storage URLs HTTPS and configure bucket CORS for the +public dashboard origin; the ingress does not rewrite those URLs. See the +[dashboard README](../../clients/dashboard/README.md). + +## Prepare + +Run commands from the repository root. Configure `crates/condite-core/.env` from +its example, including real storage settings. Choose a hostname you control: + +```sh +export DASHBOARD_HOST=dashboard.example.com +export DASHBOARD_ORIGIN="https://$DASHBOARD_HOST" +# Check CPU/RAM/disk first; this builds the Rust SDKs as well as the dashboard. +docker build -f docker/dashboard.Dockerfile \ + --build-arg CARGO_BUILD_JOBS=1 \ + --build-arg DASHBOARD_ORIGIN="$DASHBOARD_ORIGIN" \ + -t condite-dashboard:local . + +# Bootstrap core without publishing any ports. +docker compose -f docker/examples/compose.yaml run -d --name condite-bootstrap core +docker exec condite-bootstrap ctl apikey generate +# Save the generated key privately, then remove the bootstrap container. +docker stop condite-bootstrap +docker rm condite-bootstrap +read -rsp 'Dashboard API key: ' CONDITE_API_KEY; echo +export CONDITE_API_KEY +``` + +`DASHBOARD_ORIGIN` is a **build-time** host-validation setting. Setting it only at +runtime does not work; rebuild when changing the public origin. The published +image may have been built for a different origin, so these examples use a local +build. Keep keys and tunnel tokens out of Git. Back up the persistent core volume +before upgrading; startup applies database migrations. + +## Caddy: HTTPS and password protection + +Point the hostname's DNS at the server and allow inbound TCP 80/443 to **Caddy**. +Port 80 serves Caddy's HTTPS redirect/certificate handling, not the dashboard. +Generate a password hash interactively: + +```sh +docker run --rm -it caddy:2 caddy hash-password +read -rp 'Caddy password hash: ' DASHBOARD_PASSWORD_HASH +export DASHBOARD_PASSWORD_HASH +docker compose -f docker/examples/compose.yaml \ + -f docker/examples/compose.caddy.yaml up -d +``` + +Open `https://dashboard.example.com/en/` and sign in as `admin` with the password +you hashed. [Caddy automatically obtains and renews certificates](https://caddyserver.com/docs/automatic-https). +Its [basic_auth](https://caddyserver.com/docs/caddyfile/directives/basic_auth) +protects SSR pages and API requests. The [reverse proxy](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy) +preserves the public host and sets forwarded headers so dashboard write-origin +checks see the HTTPS origin. Do not cache SSR or authenticated API responses. + +For an existing Docker reverse proxy, attach it to this stack's backend network +(or use a dedicated shared ingress network), target `http://dashboard:4321`, +preserve the public Host, and overwrite forwarded host/protocol headers with +trusted values. Keep core private and enforce authentication at the proxy. +No Docker socket mount or automatic container discovery is needed here. + +## Cloudflare Tunnel: no inbound ports + +As an alternative to Caddy, create a remotely managed +[Cloudflare Tunnel](https://developers.cloudflare.com/tunnel/get-started/). +**Before publishing it**, configure a Cloudflare Access self-hosted application +for the dashboard hostname with an allow policy limited to your users. A tunnel +alone does not authenticate visitors. + +Set the tunnel's published application hostname to `dashboard.example.com` and +its service URL to `http://dashboard:4321`. Preserve the public HTTP Host header +(do not override it with the Docker service name). Use the same public HTTPS +origin that was compiled into the dashboard. + +```sh +read -rsp 'Tunnel token: ' TUNNEL_TOKEN; echo +export TUNNEL_TOKEN +docker compose -f docker/examples/compose.yaml \ + -f docker/examples/compose.cloudflared.yaml up -d +``` + +Open `https://dashboard.example.com/en/` through Access. This variant publishes +**no host ports**; cloudflared connects outbound to Cloudflare, which terminates +public HTTPS. HTTP stays on the private Docker hop to the dashboard. The tunnel +and Caddy variants are alternatives; run only one. Pin ingress images to tested +versions or digests for reproducible production deployments. diff --git a/docker/examples/compose.caddy.yaml b/docker/examples/compose.caddy.yaml new file mode 100644 index 0000000..c29d970 --- /dev/null +++ b/docker/examples/compose.caddy.yaml @@ -0,0 +1,19 @@ +services: + caddy: + image: caddy:2 + environment: + DASHBOARD_HOST: ${DASHBOARD_HOST:?Set the public dashboard hostname} + DASHBOARD_PASSWORD_HASH: ${DASHBOARD_PASSWORD_HASH:?Set a Caddy password hash} + ports: + - '80:80' + - '443:443' + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile:ro + - caddy-data:/data + - caddy-config:/config + networks: [backend, egress] + depends_on: [dashboard] + restart: unless-stopped +volumes: + caddy-data: + caddy-config: diff --git a/docker/examples/compose.cloudflared.yaml b/docker/examples/compose.cloudflared.yaml new file mode 100644 index 0000000..1e31225 --- /dev/null +++ b/docker/examples/compose.cloudflared.yaml @@ -0,0 +1,9 @@ +services: + cloudflared: + image: cloudflare/cloudflared:latest + command: tunnel --no-autoupdate run + environment: + TUNNEL_TOKEN: ${TUNNEL_TOKEN:?Set the Cloudflare Tunnel token} + networks: [backend, egress] + depends_on: [dashboard] + restart: unless-stopped diff --git a/docker/examples/compose.yaml b/docker/examples/compose.yaml new file mode 100644 index 0000000..9c4ef36 --- /dev/null +++ b/docker/examples/compose.yaml @@ -0,0 +1,28 @@ +# Use with exactly one ingress example; see README.md. +services: + core: + image: ghcr.io/hexvale-labs/condite/core:${CORE_VERSION:-0.1.0} + env_file: ../../crates/condite-core/.env + environment: + SQL_CONN_URL: turso:/app/data/condite.db + volumes: + - core-data:/app/data + networks: [backend, egress] + restart: unless-stopped + stop_grace_period: 30s + dashboard: + # Build this image for DASHBOARD_ORIGIN first (see README.md). + image: condite-dashboard:local + environment: + CONDITE_API_URL: http://core:8080 + CONDITE_API_KEY: ${CONDITE_API_KEY:?Set a dashboard API key} + networks: [backend] + depends_on: [core] + restart: unless-stopped +networks: + backend: + internal: true + # Core needs outbound access to S3; ingress needs certificates or tunnel access. + egress: {} +volumes: + core-data: diff --git a/docs/releases.md b/docs/releases.md index 21ed9fb..fc102af 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -71,6 +71,10 @@ Local builds: `docker build -f docker/core.Dockerfile -t condite-core .` and `docker build -f docker/dashboard.Dockerfile --build-arg DASHBOARD_ORIGIN=https://dashboard.example -t condite-dashboard .`. Run `bash scripts/release/smoke-images.sh COMPONENT IMAGE` before using them. +See the [dashboard ingress examples](../docker/examples/README.md) for private +Docker networking with Caddy or Cloudflare Tunnel. Core and dashboard have no +built-in TLS; do not expose their HTTP listeners directly to the internet. + ## Vencord assets Publishing a GitHub release for a matching umbrella or Vencord SemVer tag builds