Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keeps the contain on failed build #5

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/core/habitat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,27 @@ pub(crate) fn native_package_build(
})
.collect::<Vec<String>>()
.join(":");
let container_name = tmp_dir.path().file_name().unwrap();
let container_name = "hab-auto-build-native";
let container_id_output = std::process::Command::new("docker")
.args(["ps", "-aqf", &format!("name={}", container_name)])
.output()?;
let container_id = String::from_utf8_lossy(&container_id_output.stdout);
let container_id = container_id.trim();
if !container_id.is_empty() {
let exit_status = Exec::cmd("docker").arg("rm").arg(container_name).join()?;
if !exit_status.success() {
return Err(BuildError::Unexpected(eyre!(
"Failed to remove Docker container '{}'",
container_name
)));
}
}

cmd = Exec::cmd("docker")
.arg("run")
.arg("-it")
.arg("--name")
.arg(container_name)
.arg("--rm")
.arg("-v")
.arg(format!(
"{}:/src",
Expand Down