-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathcompose.rs
More file actions
80 lines (75 loc) · 2.83 KB
/
Copy pathcompose.rs
File metadata and controls
80 lines (75 loc) · 2.83 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
// SPDX-FileCopyrightText: © 2026 Phala Network <dstack@phala.network>
//
// SPDX-License-Identifier: Apache-2.0
//! build the app-compose manifest — the JSON document the VMM hashes (to derive
//! the app id) and deploys. The raw docker-compose YAML is embedded as a string.
use serde_json::json;
/// build a minimal app-compose manifest from a docker-compose YAML body
/// (single-node, no gateway).
///
/// `kms_enabled` selects KMS mode (deterministic, upgradeable per-app keys);
/// gateway and local-key-provider are off for the direct-port single-node flow.
pub fn build_app_compose(name: &str, docker_compose_yaml: &str, kms_enabled: bool) -> String {
build_app_compose_with_runtime(
name,
docker_compose_yaml,
kms_enabled,
"docker-compose",
None,
)
}
/// Build an app-compose manifest with an explicitly selected compose frontend.
/// `snapshotter` is meaningful only for `nerdctl-compose`.
pub fn build_app_compose_with_runtime(
name: &str,
docker_compose_yaml: &str,
kms_enabled: bool,
runner: &str,
snapshotter: Option<&str>,
) -> String {
build_app_compose_with_runtime_and_volumes(
name,
docker_compose_yaml,
kms_enabled,
runner,
snapshotter,
&[],
)
}
/// Build an app-compose manifest with measured verity volume declarations.
pub fn build_app_compose_with_runtime_and_volumes(
name: &str,
docker_compose_yaml: &str,
kms_enabled: bool,
runner: &str,
snapshotter: Option<&str>,
verity_volumes: &[dstack_types::VerityVolume],
) -> String {
let mut manifest = json!({
"manifest_version": if runner == "nerdctl-compose" { json!("3") } else { json!(2) },
"name": name,
"runner": runner,
"docker_compose_file": docker_compose_yaml,
"kms_enabled": kms_enabled,
"gateway_enabled": false,
"local_key_provider_enabled": false,
"public_logs": true,
"public_sysinfo": true,
"no_instance_id": false,
// don't block boot on `chronyc waitsync` — the manifest default is true,
// but the single-node direct-port flow has no gateway/RA-TLS that needs a
// pre-synced clock, and the strict wait hard-fails (→ reboot loop) whenever
// chrony has no usable source. chronyd still syncs in the background.
// (NTS is also currently broken in guest images — see dstack#745.)
"secure_time": false,
});
if let Some(snapshotter) = snapshotter {
manifest["snapshotter"] = json!(snapshotter);
}
if !verity_volumes.is_empty() {
manifest["verity_volumes"] = json!(verity_volumes);
}
// pretty-print via Value's Display (`{:#}`) — infallible, and byte-identical
// to serde_json::to_string_pretty (avoids an expect on an unfailable Result).
format!("{manifest:#}")
}