Skip to content

Commit

Permalink
set all docker envs on command (#1180)
Browse files Browse the repository at this point in the history
* set all docker envs on command

* replace with matches

* lint fix
  • Loading branch information
coffee-cup authored Sep 4, 2024
1 parent 7c8ac6e commit 1cf93c9
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/nixpacks/builder/docker/docker_image_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::nixpacks::{
};
use anyhow::{bail, Context, Ok, Result};
use std::{
env,
fs::{self, remove_dir_all, File},
process::Command,
};
Expand Down Expand Up @@ -179,22 +178,20 @@ impl DockerImageBuilder {
docker_build_cmd.arg("--cache-from").arg(value);
}

if let Some(value) = &self.options.docker_host {
env::set_var("DOCKER_HOST", value);
}
match &self.options.docker_host {
Some(value) => docker_build_cmd.env("DOCKER_HOST", value),
None => docker_build_cmd.env_remove("DOCKER_HOST"),
};

if let Some(value) = &self.options.docker_tls_verify {
if value == "1" {
env::set_var("DOCKER_TLS_VERIFY", value);
} else {
env::remove_var("DOCKER_TLS_VERIFY"); // Clear the variable to disable TLS verification
}
}
match &self.options.docker_tls_verify {
Some(value) if value == "1" => docker_build_cmd.env("DOCKER_TLS_VERIFY", value),
_ => docker_build_cmd.env_remove("DOCKER_TLS_VERIFY"), // Clear the variable to disable TLS verification
};

match &self.options.docker_cert_path {
Some(value) => env::set_var("DOCKER_CERT_PATH", value),
None => env::remove_var("DOCKER_CERT_PATH"),
}
Some(value) => docker_build_cmd.env("DOCKER_CERT_PATH", value),
None => docker_build_cmd.env_remove("DOCKER_CERT_PATH"),
};

if self.options.inline_cache {
docker_build_cmd
Expand Down

0 comments on commit 1cf93c9

Please sign in to comment.