Skip to content

Commit

Permalink
Feat/docker cert path (#1165)
Browse files Browse the repository at this point in the history
* fat: add a params to specify the docker cert path

* docs: update the docs

* fix: conflicts

* fix: liner
  • Loading branch information
cchalop1 authored Aug 27, 2024
1 parent b7e32b9 commit 8ec298e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/pages/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ nixpacks build --help
| `--no-cache` | Disable caching for the build |
| `--docker-host` | Specify host for Docker client |
| `--docker-tls-verify` | Specify if Docker client should verify the TLS (Transport Layer Security) certificates of the Docker daemon when communicating over a secure connection |
| `--docker-cert-path` | Specify the path of your cert to docker if your connection is under TLS |
| `--cache-from` | Image to consider as cache sources |
| `--inline-cache` | Enable writing cache metadata into the output image |
| `--out <dir>`, `-o` | Save output directory instead of building it with Docker |
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ enum Commands {
/// https://docs.docker.com/reference/cli/docker/buildx/build/#output
#[arg(long)]
docker_output: Option<String>,
/// Specify the path to the Docker client certificates
#[arg(long)]
docker_cert_path: Option<String>,

/// Enable writing cache metadata into the output image
#[arg(long)]
Expand Down Expand Up @@ -266,6 +269,7 @@ async fn main() -> Result<()> {
docker_tls_verify,
docker_output,
add_host,
docker_cert_path,
inline_cache,
no_error_without_start,
cpu_quota,
Expand Down Expand Up @@ -297,6 +301,7 @@ async fn main() -> Result<()> {
docker_host,
docker_tls_verify,
docker_output,
docker_cert_path,
no_error_without_start,
incremental_cache_image,
cpu_quota,
Expand Down
5 changes: 3 additions & 2 deletions src/nixpacks/builder/docker/docker_image_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ impl DockerImageBuilder {
}
}

if let Some(value) = &self.options.docker_output {
docker_build_cmd.arg("--output").arg(value);
match &self.options.docker_cert_path {
Some(value) => env::set_var("DOCKER_CERT_PATH", value),
None => env::remove_var("DOCKER_CERT_PATH"),
}

if self.options.inline_cache {
Expand Down
1 change: 1 addition & 0 deletions src/nixpacks/builder/docker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct DockerBuilderOptions {
pub docker_tls_verify: Option<String>,
pub docker_output: Option<String>,
pub add_host: Vec<String>,
pub docker_cert_path: Option<String>,
}

mod cache;
Expand Down

0 comments on commit 8ec298e

Please sign in to comment.