huskies: merge 1172 story Add Docker log rotation to project container launch args
This commit is contained in:
@@ -1352,6 +1352,10 @@ pub async fn build_project_image(
|
|||||||
/// `/home/huskies/.claude/.credentials.json` with mode 0600. Mounting to an
|
/// `/home/huskies/.claude/.credentials.json` with mode 0600. Mounting to an
|
||||||
/// intermediate path (rather than directly to the destination) ensures the
|
/// intermediate path (rather than directly to the destination) ensures the
|
||||||
/// huskies user owns the copy regardless of the host user's UID.
|
/// 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)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(crate) fn project_docker_run_args(
|
pub(crate) fn project_docker_run_args(
|
||||||
container_name: &str,
|
container_name: &str,
|
||||||
@@ -1366,6 +1370,12 @@ pub(crate) fn project_docker_run_args(
|
|||||||
let mut args = vec![
|
let mut args = vec![
|
||||||
"run".into(),
|
"run".into(),
|
||||||
"-d".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(),
|
"--name".into(),
|
||||||
container_name.to_string(),
|
container_name.to_string(),
|
||||||
"-p".into(),
|
"-p".into(),
|
||||||
@@ -1847,6 +1857,24 @@ mod tests {
|
|||||||
&& w[1] == "HUSKIES_GATEWAY_URL=http://host.docker.internal:3000"),
|
&& 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:?}"
|
"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]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user