Skip to content

Commit b23ac3e

Browse files
committed
refactor(launcher): set stable compose project via top-level name
Set the project name declaratively as a top-level `name: mpc-node` in the rendered compose file instead of passing `-p mpc` on the command line (per review). The project identity now travels with the compose config and is covered by render tests. Behaviour is unchanged: a stable project name keeps the container reused across restarts, preserving its logs.
1 parent 3e679db commit b23ac3e

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

crates/tee-launcher/assets/mpc-node-docker-compose.tee.template.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: mpc-node
2+
13
services:
24
mpc-node:
35
image: "{{IMAGE_NAME}}@{{MANIFEST_DIGEST}}"

crates/tee-launcher/assets/mpc-node-docker-compose.template.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: mpc-node
2+
13
services:
24
mpc-node:
35
image: "{{IMAGE_NAME}}@{{MANIFEST_DIGEST}}"

crates/tee-launcher/src/compose.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ pub fn launch_mpc_container(
5959
let compose_file = render_compose_file(platform, port_mappings, image_name, manifest_digest)?;
6060
let compose_path = compose_file.path().display().to_string();
6161

62-
// Use a stable compose project (`-p`) so the container is reused across
63-
// restarts rather than recreated, preserving its logs. Compose
64-
// recreates it only when the rendered config (e.g. image digest) changes.
62+
// The compose file pins a stable top-level project `name`, so the
63+
// container is reused across restarts rather than recreated, preserving its
64+
// logs. Compose recreates it only when the rendered config (e.g. image
65+
// digest) changes.
6566
let run_output = Command::new("docker")
66-
.args(["compose", "-p", "mpc", "-f", &compose_path, "up", "-d"])
67+
.args(["compose", "-f", &compose_path, "up", "-d"])
6768
.output()
6869
.map_err(|inner| LauncherError::DockerRunFailed {
6970
image_hash: manifest_digest.clone(),
@@ -263,4 +264,19 @@ mod tests {
263264
// then
264265
assert!(!rendered.contains("environment:"));
265266
}
267+
268+
#[test]
269+
fn includes_stable_project_name() {
270+
// given
271+
let port_mappings = empty_port_mappings();
272+
let digest = sample_digest();
273+
274+
// when
275+
let rendered = render(Platform::Tee, &port_mappings, &digest);
276+
277+
// then — a stable top-level project name keeps Compose reusing the
278+
// container across restarts instead of recreating it (which would wipe
279+
// its logs)
280+
assert!(rendered.contains("name: mpc-node"));
281+
}
266282
}

0 commit comments

Comments
 (0)