Repository navigation
Expand file tree
/
Copy pathdocker-compose.split.yml
More file actions
105 lines (101 loc) · 4.69 KB
/
Copy pathdocker-compose.split.yml
File metadata and controls
105 lines (101 loc) · 4.69 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# CoreScope — split containers: the UI in its own web container and the
# server in the usual image.
#
# The web container (Dockerfile.web, Caddy) serves the static UI and forwards
# /api and /ws to the server, so both share one origin: no CORS settings. With
# user management on, set the server's userManagement.publicBaseUrl to the web
# container's public origin (scheme and port included): logins and other
# writes are checked against it. The server container is unchanged and still
# serves everything, the classic UI included, on port 3000 inside the compose
# network; publish it too if you want to reach that directly. For per-IP
# limits, the server trusts the web container's fixed address: see networks.
#
# Usage: CORESCOPE_IMAGE=ghcr.io/kpa-clawbot/corescope:edge \
# docker compose -f docker-compose.split.yml up -d --build
# Docs: docs/deployment.md, "Deployment modes"
#
# Variables (shell or .env):
# CORESCOPE_IMAGE required: the server image of the same version as this
# checkout, which the web image is built from. :edge on
# master, :vX.Y.Z on a release tag. There is no default, so
# a release server is never paired with a newer UI unasked.
# DATA_DIR the server's data directory. Default ./data
# HTTP_PORT default 80; HTTPS_PORT default 443 (TCP and UDP)
# SITE_ADDRESS :80 (default), or a domain name for automatic HTTPS, which
# needs the default ports: certificate issuance and the
# HTTP/3 advertisement both assume 80 and 443
# GIT_COMMIT the UI's cache buster; default the build time
# CHANNEL static (default), or beta, next, dev for a badge
# MQTT_BIND where the server's built-in broker is published. Default
# 127.0.0.1: it accepts anonymous clients, so set 0.0.0.0
# only to let gateways on a network you trust publish to it.
# MQTT_PORT default 1883
# SPLIT_NET the compose network's /24, as its first three octets.
# Default 172.30.83, which puts the web container at
# 172.30.83.200. Change it only if Docker reports that the
# pool overlaps another network, and update the server's
# trustedProxies to match.
services:
corescope:
image: ${CORESCOPE_IMAGE:?set CORESCOPE_IMAGE to the server image of this checkout's version, e.g. ghcr.io/kpa-clawbot/corescope:edge on master or :vX.Y.Z on a release tag}
ports:
- "${MQTT_BIND:-127.0.0.1}:${MQTT_PORT:-1883}:1883"
volumes:
- ${DATA_DIR:-./data}:/app/data
environment:
- DISABLE_CADDY=true
- DISABLE_MOSQUITTO=${DISABLE_MOSQUITTO:-false}
# Public URL for link previews (og:image, og:url). Unset: the image uses
# the origin each request reached and og:url is left out.
# e.g. CORESCOPE_URL=https://analyzer.example.org
- CORESCOPE_URL=${CORESCOPE_URL:-}
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:3000/api/healthz"]
interval: 30s
timeout: 5s
retries: 3
web:
build:
context: .
dockerfile: Dockerfile.web
args:
GIT_COMMIT: ${GIT_COMMIT:-}
CHANNEL: ${CHANNEL:-static}
# The web image is static: the site URL is fixed when it is built.
CORESCOPE_URL: ${CORESCOPE_URL:-}
image: corescope-web:latest
ports:
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
# HTTP/3: Caddy advertises it on 443 when SITE_ADDRESS is a domain.
- "${HTTPS_PORT:-443}:443/udp"
volumes:
- web-caddy-data:/data
environment:
- BACKEND=corescope:3000
- SITE_ADDRESS=${SITE_ADDRESS:-:80}
networks:
default:
# The one address the server's trustedProxies lists; see networks.
ipv4_address: "${SPLIT_NET:-172.30.83}.200"
depends_on:
- corescope
restart: unless-stopped
networks:
# A fixed subnet gives the web container a fixed address, so the server's
# webSocket.trustedProxies and userManagement.trustedProxies can list it
# alone (172.30.83.200 by default) and still match after a recreate. Never
# list the whole subnet: it holds the gateway address too, and a client
# that reaches a published port 3000 through Docker's proxy arrives from
# there, so its own X-Forwarded-For would be believed.
default:
ipam:
config:
- subnet: "${SPLIT_NET:-172.30.83}.0/24"
# Automatic addresses come from the lower half, so no container
# can take the web container's.
ip_range: "${SPLIT_NET:-172.30.83}.0/25"
volumes:
# Caddy's TLS certificates when SITE_ADDRESS is a domain name.
web-caddy-data: