-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
211 lines (203 loc) · 6.42 KB
/
Copy pathdocker-compose.yml
File metadata and controls
211 lines (203 loc) · 6.42 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
version: "3.8"
# CHV local development stack
# Note: chv-webui-bff is embedded in the chv-controlplane binary (port 8080).
#
# Services:
# chv-controlplane — gRPC control plane + HTTP BFF API
# chv-stord — storage daemon (Unix socket)
# chv-nwd — network daemon (Unix socket)
# chv-agent — node agent (supervises VM runtime; stord/nwd run in separate containers above)
# chv-webui — nginx serving the SvelteKit static app + proxying API/BFF/WebSocket
#
# Bootstrap token must be created manually after the controlplane starts, e.g.:
# docker compose exec chv-controlplane chv-controlplane --generate-bootstrap-token > token.txt
services:
chv-controlplane:
build:
context: .
dockerfile: Dockerfile
command: >
sh -c "mkdir -p /run/chv/controlplane /var/lib/chv /usr/local/share/chv/migrations &&
cat > /etc/chv/controlplane.toml <<'EOF'
grpc_bind = \"0.0.0.0:8443\"
http_bind = \"0.0.0.0:8080\"
log_level = \"info\"
runtime_dir = \"/run/chv/controlplane\"
agent_runtime_dir = \"/var/lib/chv/agent\"
jwt_secret = \"chv-local-dev-secret-do-not-use-in-production-ever\"
[database]
url = \"sqlite:///var/lib/chv/controlplane.db\"
migrations_dir = \"/usr/local/share/chv/migrations\"
max_connections = 4
min_connections = 1
acquire_timeout_secs = 5
EOF
chv-controlplane /etc/chv/controlplane.toml"
ports:
- "8080:8080" # HTTP BFF / Admin API
- "8443:8443" # gRPC (agent enrollment)
volumes:
- chv-data:/var/lib/chv
- chv-run:/run/chv
- chv-certs:/etc/chv/certs
networks:
- chv
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
chv-stord:
build:
context: .
dockerfile: Dockerfile
command: >
sh -c "mkdir -p /var/lib/chv/storage/localdisk /run/chv/stord &&
cat > /etc/chv/stord.toml <<'EOF'
socket_path = \"/run/chv/stord/api.sock\"
runtime_dir = \"/var/lib/chv/storage/localdisk\"
log_level = \"info\"
EOF
chv-stord /etc/chv/stord.toml"
volumes:
- chv-data:/var/lib/chv
- chv-run:/run/chv
networks:
- chv
restart: unless-stopped
depends_on:
- chv-controlplane
chv-nwd:
build:
context: .
dockerfile: Dockerfile
command: >
sh -c "mkdir -p /run/chv/nwd &&
cat > /etc/chv/nwd.toml <<'EOF'
socket_path = \"/run/chv/nwd/api.sock\"
runtime_dir = \"/run/chv/nwd\"
log_level = \"info\"
EOF
chv-nwd /etc/chv/nwd.toml"
volumes:
- chv-run:/run/chv
networks:
- chv
restart: unless-stopped
depends_on:
chv-controlplane:
condition: service_healthy
chv-agent:
build:
context: .
dockerfile: Dockerfile
privileged: true
devices:
- /dev/kvm:/dev/kvm
command: >
sh -c "mkdir -p /var/lib/chv/agent /run/chv/agent /var/lib/chv/cache /etc/chv/certs &&
cat > /etc/chv/agent.toml <<'EOF'
socket_path = \"/run/chv/agent/api.sock\"
runtime_dir = \"/var/lib/chv/agent\"
log_level = \"info\"
control_plane_addr = \"http://chv-controlplane:8443\"
stord_socket = \"/run/chv/stord/api.sock\"
nwd_socket = \"/run/chv/nwd/api.sock\"
chv_binary_path = \"/usr/bin/cloud-hypervisor\"
stord_binary_path = \"/dev/null\"
nwd_binary_path = \"/dev/null\"
cache_path = \"/var/lib/chv/cache/agent-cache.json\"
node_id = \"\"
metrics_bind = \"0.0.0.0:9901\"
storage_base_dir = \"/var/lib/chv/storage\"
bootstrap_token_path = \"/etc/chv/bootstrap.token\"
tls_cert_path = \"/run/chv/agent/agent.crt\"
tls_key_path = \"/run/chv/agent/agent.key\"
ca_cert_path = \"/etc/chv/certs/ca.crt\"
console_bind = \"0.0.0.0:8444\"
jwt_secret = \"chv-local-dev-secret-do-not-use-in-production-ever\"
EOF
chv-agent /etc/chv/agent.toml"
ports:
- "8444:8444" # Serial console WebSocket
- "9901:9901" # Agent metrics
volumes:
- chv-data:/var/lib/chv
- chv-run:/run/chv
- chv-certs:/etc/chv/certs
networks:
- chv
restart: unless-stopped
depends_on:
- chv-controlplane
- chv-stord
- chv-nwd
chv-webui:
build:
context: .
dockerfile: Dockerfile
command: >
sh -c "cat > /etc/nginx/sites-enabled/default <<'EOF'
server {
listen 80;
server_name _;
root /opt/chv/ui;
index index.html;
location / {
try_files \$$uri \$$uri/ /index.html;
}
location = /index.html {
add_header Cache-Control \"no-cache, no-store, must-revalidate\";
}
location /_app/immutable/ {
add_header Cache-Control \"public, max-age=31536000, immutable\";
}
location /api/ {
proxy_pass http://chv-controlplane:8080;
proxy_http_version 1.1;
proxy_set_header Host \$$host;
proxy_set_header X-Real-IP \$$remote_addr;
proxy_set_header X-Forwarded-For \$$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$$scheme;
proxy_intercept_errors off;
}
location /v1/ {
proxy_pass http://chv-controlplane:8080;
proxy_http_version 1.1;
proxy_set_header Host \$$host;
proxy_set_header X-Real-IP \$$remote_addr;
proxy_set_header X-Forwarded-For \$$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$$scheme;
proxy_intercept_errors off;
}
location /ws/vms/ {
proxy_pass http://chv-agent:8444/vms/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$$http_upgrade;
proxy_set_header Connection \"upgrade\";
proxy_set_header Host \$$host;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml+rss text/javascript;
}
EOF
nginx -g 'daemon off;'"
ports:
- "80:80" # Web UI
depends_on:
- chv-controlplane
- chv-agent
networks:
- chv
restart: unless-stopped
volumes:
chv-data:
chv-run:
chv-certs:
networks:
chv:
driver: bridge