Skip to content

Commit

Permalink
Switch build to only require the dockerfile directory (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinuhma authored Oct 28, 2022
1 parent 7c6b6bd commit 8819541
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
14 changes: 5 additions & 9 deletions src/bin/nitrogen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ enum Commands {

/// Build a Nitro EIF from a given Dockerfile
Build {
/// Docker context directory
context: String,
/// Dockerfile location
dockerfile: String,
/// Dockerfile directory
dockerfile_dir: String,
/// Output EIF location
#[arg(short, long, default_value_t = String::from("./nitrogen.eif"))]
eif: String,
Expand Down Expand Up @@ -153,12 +151,11 @@ async fn main() -> Result<(), Error> {
Ok(())
}
Commands::Build {
dockerfile,
context,
dockerfile_dir,
eif,
} => {
info!(context, dockerfile, "Building EIF from dockerfile.");
let out = build(&dockerfile, &context, &eif).await?;
info!(dockerfile_dir, "Building EIF from dockerfile.");
let out = build(&dockerfile_dir, &eif).await?;
debug!(docker_output=?out, "Docker output:");
Ok(())
}
Expand Down Expand Up @@ -237,7 +234,6 @@ async fn main() -> Result<(), Error> {
let eif_path = &format!("{}.eif", name);

build(
&dockerfile_path.to_str().unwrap().to_string(),
&proj_dir.to_str().unwrap().to_string(),
eif_path,
)
Expand Down
5 changes: 2 additions & 3 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use tracing::instrument;

#[instrument(level = "debug")]
pub async fn build(
dockerfile: &String,
context: &String,
dockerfile_dir: &String,
eif_name: &String,
) -> Result<Output, Error> {
let out = Command::new("docker")
.args(["build", "-t", "nitrogen-build", context, "-f", dockerfile])
.args(["build", "-t", "nitrogen-build", dockerfile_dir, "-f", &format!("{}/.", dockerfile_dir)])
.output()
.await?;
if !out.status.success() {
Expand Down

0 comments on commit 8819541

Please sign in to comment.