-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathdocker-compose.https.yml
More file actions
76 lines (73 loc) · 2.81 KB
/
Copy pathdocker-compose.https.yml
File metadata and controls
76 lines (73 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Optional public-domain HTTPS gateway for either Docker deployment path.
#
# Usage (Docker Compose 2.24.4+):
# export OPENBILICLAW_DOMAIN=obc.example.com
# docker compose -f docker-compose.prebuilt.yml -f docker-compose.https.yml up -d
# docker exec -it openbiliclaw-backend openbiliclaw set-password
# docker restart openbiliclaw-backend openbiliclaw-caddy
#
# Caddy obtains and renews the public certificate automatically. It shares the
# backend container's network namespace so the only trusted proxy hop is
# loopback; :8420 is republished on host loopback while :80/:443 become the
# public entrypoints. The default compose files remain HTTP/LAN-compatible when
# this overlay is not selected.
services:
openbiliclaw-backend:
environment:
# Uvicorn accepts forwarded scheme/client headers only from the Caddy
# process sharing this container's loopback interface. Never widen this
# while the backend is reachable from an untrusted network.
FORWARDED_ALLOW_IPS: "127.0.0.1"
ports: !override
- "127.0.0.1:8420:8420"
- "80:80"
- "443:443"
- "443:443/udp"
openbiliclaw-caddy:
image: caddy:2.11.4-alpine
container_name: openbiliclaw-caddy
network_mode: "service:openbiliclaw-backend"
depends_on:
openbiliclaw-backend:
condition: service_healthy
environment:
OPENBILICLAW_DOMAIN: ${OPENBILICLAW_DOMAIN:?Set OPENBILICLAW_DOMAIN to a public DNS name, for example obc.example.com}
# Fail closed: publishing a public hostname must never create a window in
# which the API password gate is still disabled. The container waits on
# loopback without binding :80/:443; after set-password + backend restart,
# it automatically execs the production-ready Caddy reverse proxy.
command:
- /bin/sh
- -ec
- |
if ! curl --fail --silent http://127.0.0.1:8420/api/auth/status |
grep -q '"enabled":true'; then
echo "Waiting for the OpenBiliClaw Web password gate to be enabled..."
fi
until curl --fail --silent http://127.0.0.1:8420/api/auth/status |
grep -q '"enabled":true'; do
sleep 5
done
exec caddy reverse-proxy \
--from "$${OPENBILICLAW_DOMAIN}" \
--to 127.0.0.1:8420
volumes:
- openbiliclaw_caddy_data:/data
- openbiliclaw_caddy_config:/config
healthcheck:
test:
- CMD-SHELL
- >-
curl --fail --silent --show-error
--resolve "$${OPENBILICLAW_DOMAIN}:443:127.0.0.1"
"https://$${OPENBILICLAW_DOMAIN}/api/health" >/dev/null
interval: 30s
timeout: 10s
start_period: 5m
retries: 3
restart: unless-stopped
volumes:
openbiliclaw_caddy_data:
name: openbiliclaw_caddy_data
openbiliclaw_caddy_config:
name: openbiliclaw_caddy_config