Skip to content

Commit

Permalink
only check if docker exists if not building (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup authored Aug 15, 2024
1 parent 232fe42 commit 87aeabb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use providers::{
rust::RustProvider, scala::ScalaProvider, staticfile::StaticfileProvider, swift::SwiftProvider,
zig::ZigProvider, Provider,
};
use std::process::Command;

mod chain;
#[macro_use]
Expand Down Expand Up @@ -152,9 +153,23 @@ pub async fn create_docker_image(
std::process::exit(1);
}

if build_options.out_dir.is_none() {
ensure_docker_exists()?;
}

builder
.create_image(app.source.to_str().unwrap(), &plan, &environment)
.await?;

Ok(())
}

fn ensure_docker_exists() -> Result<()> {
let mut docker_build_cmd = Command::new("docker");

if docker_build_cmd.output().is_err() {
bail!("Please install Docker to build the app https://docs.docker.com/engine/install/");
}

Ok(())
}
4 changes: 0 additions & 4 deletions src/nixpacks/builder/docker/docker_image_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ impl DockerImageBuilder {
) -> Result<Command> {
let mut docker_build_cmd = Command::new("docker");

if docker_build_cmd.output().is_err() {
bail!("Please install Docker to build the app https://docs.docker.com/engine/install/")
}

// Enable BuildKit for all builds
docker_build_cmd.env("DOCKER_BUILDKIT", "1");

Expand Down

0 comments on commit 87aeabb

Please sign in to comment.