Skip to content

Commit

Permalink
feat(docker-build): pass additional workspace directory
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwolrg committed Nov 2, 2024
1 parent 4370aad commit 648490c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/build/src/command/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ pub(crate) fn create_docker_command(
.expect("Failed to canonicalize program directory")
.try_into()
.unwrap();
let workspace_root = &program_metadata.workspace_root;

let workspace_root: &Utf8PathBuf = &args
.workspace_directory
.as_deref()
.map(|workspace_path| {
std::path::Path::new(workspace_path)
.to_path_buf()
.canonicalize()
.expect("Failed to canonicalize workspace directory")
.try_into()
.unwrap()
})
.unwrap_or_else(|| program_metadata.workspace_root.clone());

// Check if docker is installed and running.
let docker_check = Command::new("docker")
Expand Down
9 changes: 9 additions & 0 deletions crates/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ pub struct BuildArgs {
default_value = DEFAULT_OUTPUT_DIR
)]
pub output_directory: String,
#[clap(
alias = "workspace-dir",
long,
action,
help = "Optional workspace directory to be used",
default_value = None
)]
pub workspace_directory: Option<String>,
}

// Implement default args to match clap defaults.
Expand All @@ -84,6 +92,7 @@ impl Default for BuildArgs {
output_directory: DEFAULT_OUTPUT_DIR.to_string(),
locked: false,
no_default_features: false,
workspace_directory: None,
}
}
}
Expand Down

0 comments on commit 648490c

Please sign in to comment.