Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: debug mode #1254

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
#[arg(long)]
docker_cert_path: Option<String>,

/// 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,
Expand Down Expand Up @@ -254,7 +258,7 @@
println!("{}", providers.join(", "));
}
// Generate a Dockerfile and builds a container, using any specified build options.
Commands::Build {

Check failure on line 261 in src/main.rs

View workflow job for this annotation

GitHub Actions / Check

pattern does not mention field `debug`

Check failure on line 261 in src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

pattern does not mention field `debug`

Check failure on line 261 in src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (MSRV) (ubuntu-latest)

pattern does not mention field `debug`

Check failure on line 261 in src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (macos-latest)

pattern does not mention field `debug`
path,
name,
out,
Expand Down Expand Up @@ -287,7 +291,7 @@
cache_key
};

let build_options = &DockerBuilderOptions {

Check failure on line 294 in src/main.rs

View workflow job for this annotation

GitHub Actions / Check

missing field `debug` in initializer of `DockerBuilderOptions`

Check failure on line 294 in src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

missing field `debug` in initializer of `DockerBuilderOptions`

Check failure on line 294 in src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (MSRV) (ubuntu-latest)

missing field `debug` in initializer of `DockerBuilderOptions`

Check failure on line 294 in src/main.rs

View workflow job for this annotation

GitHub Actions / Test Suite (macos-latest)

missing field `debug` in initializer of `DockerBuilderOptions`
name,
tags: tag,
labels: label,
Expand Down
11 changes: 11 additions & 0 deletions src/nixpacks/builder/docker/docker_image_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ fn get_output_dir(app_src: &str, options: &DockerBuilderOptions) -> Result<Outpu
}
}

// TODO need to quote the output here otherwise the build command will fail with special char ENV vars

fn command_to_string(command: &Command) -> String {
let args = command
.get_args()
.map(|arg| arg.to_string_lossy())
.collect::<Vec<_>>();

format!(
"{} {}",
command.get_program().to_string_lossy(),
Expand Down Expand Up @@ -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")
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 @@ -21,6 +21,7 @@ pub struct DockerBuilderOptions {
pub cpu_quota: Option<String>,
pub memory: Option<String>,
pub verbose: bool,
pub debug: bool,
pub docker_host: Option<String>,
pub docker_tls_verify: Option<String>,
pub docker_output: Option<String>,
Expand Down
Loading