Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(local): bound Docker logs and preserve LocalStack (#7831)

Peter Chinman15c50190e29f
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index e05a5a0bba..9f3f60096c 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -9,6 +9,12 @@ include:
- infra/stacks/fusionauth-instance/docker-compose.yml
x-common-env: &common-env
+ # Bound console logs even when a worker repeatedly fails.
+ logging:
+ driver: json-file
+ options:
+ max-size: "20m"
+ max-file: "3"
# The xtask orchestrator points this at a per-instance generated env file via
# MACRO_ENV_FILE (run-local/run-dev). Defaults to .env for any legacy/manual
# `docker compose` invocation, and is optional so a missing file is not fatal.
diff --git a/docs/RUNNING_LOCALLY.md b/docs/RUNNING_LOCALLY.md
index ece69fb015..df0d81aae6 100644
--- a/docs/RUNNING_LOCALLY.md
+++ b/docs/RUNNING_LOCALLY.md
@@ -235,6 +235,11 @@ Keys in the file override the code-defined defaults, so you only need to list th
## Tracing, Logs, and the Debug Browser
+Local service console logs rotate at 20 MB per file and retain three files per
+container. The limits apply when a container is created; recreate older
+containers with the existing Compose project/files to adopt them. Repeated
+worker errors still need their underlying dependency or configuration fixed.
+
`just run_local` and `just stack up` support two global (per-machine, shared
across instances) debugging containers:
diff --git a/tooling/xtask/crates/xtask_local/src/local.rs b/tooling/xtask/crates/xtask_local/src/local.rs
index 9b8b4971a9..26c0928111 100644
--- a/tooling/xtask/crates/xtask_local/src/local.rs
+++ b/tooling/xtask/crates/xtask_local/src/local.rs
@@ -976,7 +976,8 @@ fn evict_other_collector(stage: &Stage, wanted_service: &str) {
/// Start a profile-gated service from the base compose file under the global
/// `macro` project (one per machine, shared across instances, left running
/// across invocations) — the pattern the trace collectors and headless Chrome
-/// share.
+/// share. Keep other containers in the shared project: the base compose file
+/// does not include generated infrastructure services such as LocalStack.
fn start_global_compose_service(
stage: &Stage,
profile: &str,
@@ -994,7 +995,6 @@ fn start_global_compose_service(
.arg(profile)
.arg("up")
.arg("-d")
- .arg("--remove-orphans")
.arg(service);
stage.run(&format!("Starting {profile} {label}"), &mut up)
}
diff --git a/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs b/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs
index 4f24b3f4ea..5446d8e0a4 100644
--- a/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs
@@ -494,6 +494,18 @@ fn apply_tags(value: &mut Value, mode: Mode, instance: &Instance) {
}
}
}
+ // Generated companions do not inherit the base compose's common settings.
+ // Apply after adding aux overrides so every generated service is covered.
+ for service in services.values_mut().filter_map(Value::as_mapping_mut) {
+ service.insert(
+ "logging".into(),
+ serde_yaml::to_value(serde_json::json!({
+ "driver": "json-file",
+ "options": { "max-size": "20m", "max-file": "3" }
+ }))
+ .expect("logging configuration is serializable"),
+ );
+ }
}
/// Define the per-instance external networks and volumes (named-instance only).
diff --git a/tooling/xtask/crates/xtask_local/src/local/gen_compose/test.rs b/tooling/xtask/crates/xtask_local/src/local/gen_compose/test.rs
index 25f17dcdb7..1ba1c78565 100644
--- a/tooling/xtask/crates/xtask_local/src/local/gen_compose/test.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/gen_compose/test.rs
@@ -1,5 +1,32 @@
use super::*;
+#[test]
+fn generated_services_have_bounded_console_logs_in_every_mode() {
+ for mode in [Mode::Local, Mode::Dev] {
+ for name in [None, Some("logging-test")] {
+ let instance = Instance::derive(name, None).unwrap();
+ let mut services = IndexMap::new();
+ for svc in services_for_mode(mode) {
+ services.insert(svc.compose_name.to_string(), Some(dct::Service::default()));
+ }
+ add_localstack_service(&mut services, &instance);
+ add_proxy_service(&mut services, &instance, false, false);
+ let compose = dct::Compose {
+ services: dct::Services(services),
+ ..Default::default()
+ };
+ let mut value = serde_yaml::to_value(compose).unwrap();
+ apply_tags(&mut value, mode, &instance);
+
+ for service in value["services"].as_mapping().unwrap().values() {
+ assert_eq!(service["logging"]["driver"], "json-file");
+ assert_eq!(service["logging"]["options"]["max-size"], "20m");
+ assert_eq!(service["logging"]["options"]["max-file"], "3");
+ }
+ }
+ }
+}
+
#[test]
fn fusionauth_kickstart_is_privately_relabelled_and_replaces_inherited_mounts() {
for name in [None, Some("selinux-test")] {