diff --git a/src/main.rs b/src/main.rs index b66dc2750..90749188f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -163,6 +163,10 @@ enum Commands { #[arg(long)] docker_cert_path: Option, + /// Open an interactive shell if the build fails + #[arg(long)] + debug: bool, + /// Enable writing cache metadata into the output image #[arg(long)] inline_cache: bool, diff --git a/src/nixpacks/builder/docker/docker_image_builder.rs b/src/nixpacks/builder/docker/docker_image_builder.rs index 39cf8bed1..00f1c9229 100644 --- a/src/nixpacks/builder/docker/docker_image_builder.rs +++ b/src/nixpacks/builder/docker/docker_image_builder.rs @@ -36,11 +36,14 @@ fn get_output_dir(app_src: &str, options: &DockerBuilderOptions) -> Result String { let args = command .get_args() .map(|arg| arg.to_string_lossy()) .collect::>(); + format!( "{} {}", command.get_program().to_string_lossy(), @@ -145,8 +148,16 @@ impl DockerImageBuilder { // Enable BuildKit for all builds docker_build_cmd.env("DOCKER_BUILDKIT", "1"); + + if self.options.debug { + docker_build_cmd.env("BUILDX_EXPERIMENTAL", "1"); + } docker_build_cmd + .arg("buildx") + .arg("debug") + .arg("--invoke") + .arg("bash") .arg("build") .arg(&output.root) .arg("-f") diff --git a/src/nixpacks/builder/docker/mod.rs b/src/nixpacks/builder/docker/mod.rs index f12d05be8..7357e4c93 100644 --- a/src/nixpacks/builder/docker/mod.rs +++ b/src/nixpacks/builder/docker/mod.rs @@ -21,6 +21,7 @@ pub struct DockerBuilderOptions { pub cpu_quota: Option, pub memory: Option, pub verbose: bool, + pub debug: bool, pub docker_host: Option, pub docker_tls_verify: Option, pub docker_output: Option,