🛰️ export from upstream (a18006f)
This commit is contained in:
@@ -879,6 +879,11 @@ async fn run_docker_build(
|
|||||||
let mut cmd = Command::new(docker);
|
let mut cmd = Command::new(docker);
|
||||||
cmd.args(["build", "-t", &format!("{image}:latest")]);
|
cmd.args(["build", "-t", &format!("{image}:latest")]);
|
||||||
|
|
||||||
|
let uid = id_flag("-u").await.unwrap_or_else(|_| "1000".into());
|
||||||
|
let gid = id_flag("-g").await.unwrap_or_else(|_| "1000".into());
|
||||||
|
cmd.args(["--build-arg", &format!("SANDCAGE_UID={uid}")]);
|
||||||
|
cmd.args(["--build-arg", &format!("SANDCAGE_GID={gid}")]);
|
||||||
|
|
||||||
if no_cache {
|
if no_cache {
|
||||||
cmd.arg("--no-cache");
|
cmd.arg("--no-cache");
|
||||||
}
|
}
|
||||||
@@ -1000,15 +1005,20 @@ pub async fn build_images(force: bool, service_filter: &[String]) -> Result<()>
|
|||||||
let hashes_path = build_hashes_path()?;
|
let hashes_path = build_hashes_path()?;
|
||||||
let mut stored = read_stored_hashes(&hashes_path)?;
|
let mut stored = read_stored_hashes(&hashes_path)?;
|
||||||
|
|
||||||
|
let uid = id_flag("-u").await.unwrap_or_else(|_| "1000".into());
|
||||||
|
let gid = id_flag("-g").await.unwrap_or_else(|_| "1000".into());
|
||||||
|
let uid_suffix = format!("\n# uid={uid} gid={gid}");
|
||||||
|
|
||||||
for (image, bundled_dockerfile) in images {
|
for (image, bundled_dockerfile) in images {
|
||||||
let short_name = image.strip_prefix("sandcage-").unwrap_or(image);
|
let short_name = image.strip_prefix("sandcage-").unwrap_or(image);
|
||||||
let override_path = overrides.get(short_name);
|
let override_path = overrides.get(short_name);
|
||||||
|
|
||||||
let current_hash = if let Some(path) = override_path {
|
let dockerfile_content = if let Some(path) = override_path {
|
||||||
sha256_hex(&read_dockerfile_at(path)?)
|
read_dockerfile_at(path)?
|
||||||
} else {
|
} else {
|
||||||
sha256_hex(bundled_dockerfile)
|
bundled_dockerfile.to_string()
|
||||||
};
|
};
|
||||||
|
let current_hash = sha256_hex(&format!("{dockerfile_content}{uid_suffix}"));
|
||||||
|
|
||||||
let needs_build = force || stored.get(image) != Some(¤t_hash);
|
let needs_build = force || stored.get(image) != Some(¤t_hash);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user