From 23f2934e1f934a68d456a390d843d7c58dbfb296 Mon Sep 17 00:00:00 2001 From: Huskies Agent Date: Thu, 16 Jul 2026 09:37:51 +0000 Subject: [PATCH] huskies: merge 1172 story Add Docker log rotation to project container launch args --- .../src/chat/transport/matrix/new_project.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/server/src/chat/transport/matrix/new_project.rs b/server/src/chat/transport/matrix/new_project.rs index b12fe821..185938a3 100644 --- a/server/src/chat/transport/matrix/new_project.rs +++ b/server/src/chat/transport/matrix/new_project.rs @@ -1352,6 +1352,10 @@ pub async fn build_project_image( /// `/home/huskies/.claude/.credentials.json` with mode 0600. Mounting to an /// intermediate path (rather than directly to the destination) ensures the /// huskies user owns the copy regardless of the host user's UID. +/// +/// Log rotation flags (`--log-driver json-file`, `max-size=50m`, `max-file=3`) +/// match `docker/docker-compose.yml` so containers launched directly via +/// `docker run` don't grow logs unbounded the way compose-launched ones can't. #[allow(clippy::too_many_arguments)] pub(crate) fn project_docker_run_args( container_name: &str, @@ -1366,6 +1370,12 @@ pub(crate) fn project_docker_run_args( let mut args = vec![ "run".into(), "-d".into(), + "--log-driver".into(), + "json-file".into(), + "--log-opt".into(), + "max-size=50m".into(), + "--log-opt".into(), + "max-file=3".into(), "--name".into(), container_name.to_string(), "-p".into(), @@ -1847,6 +1857,24 @@ mod tests { && w[1] == "HUSKIES_GATEWAY_URL=http://host.docker.internal:3000"), "expected -e HUSKIES_GATEWAY_URL=http://host.docker.internal:3000 in docker args, got: {args:?}" ); + assert!( + pairs + .iter() + .any(|w| w[0] == "--log-driver" && w[1] == "json-file"), + "expected --log-driver json-file in docker args, got: {args:?}" + ); + assert!( + pairs + .iter() + .any(|w| w[0] == "--log-opt" && w[1] == "max-size=50m"), + "expected --log-opt max-size=50m in docker args, got: {args:?}" + ); + assert!( + pairs + .iter() + .any(|w| w[0] == "--log-opt" && w[1] == "max-file=3"), + "expected --log-opt max-file=3 in docker args, got: {args:?}" + ); } #[test]