From 11d87b4e3d0e6c5dec6d307808669d975c7cf97d Mon Sep 17 00:00:00 2001 From: Jake Runzer Date: Wed, 14 Sep 2022 11:21:41 -0400 Subject: [PATCH] Error if no start phase or start command (#547) --- src/lib.rs | 8 +------- src/nixpacks/builder/docker/docker_image_builder.rs | 5 +++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c880dbecb..6193d4a99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ use crate::nixpacks::{ nix::pkg::Pkg, plan::{generator::NixpacksBuildPlanGenerator, BuildPlan, PlanGenerator}, }; -use anyhow::{bail, Result}; +use anyhow::Result; use nixpacks::plan::generator::GeneratePlanOptions; use providers::{ clojure::ClojureProvider, crystal::CrystalProvider, csharp::CSharpProvider, dart::DartProvider, @@ -93,12 +93,6 @@ pub fn create_docker_image( let mut generator = NixpacksBuildPlanGenerator::new(get_providers(), plan_options.clone()); let plan = generator.generate_plan(&app, &environment)?; - if let Some(ref phase) = plan.start_phase { - if phase.cmd.is_none() && !build_options.no_error_without_start { - bail!("No start command could be found") - } - } - let logger = Logger::new(); let builder = DockerImageBuilder::new(logger, build_options.clone()); builder.create_image(app.source.to_str().unwrap(), &plan, &environment)?; diff --git a/src/nixpacks/builder/docker/docker_image_builder.rs b/src/nixpacks/builder/docker/docker_image_builder.rs index 54d391500..37007cf83 100644 --- a/src/nixpacks/builder/docker/docker_image_builder.rs +++ b/src/nixpacks/builder/docker/docker_image_builder.rs @@ -48,6 +48,11 @@ impl ImageBuilder for DockerImageBuilder { println!("{}", plan.get_build_string()?); + let start = plan.start_phase.clone().unwrap_or_default(); + if start.cmd.is_none() && !self.options.no_error_without_start { + bail!("No start command could be found") + } + self.write_app(app_src, &output).context("Writing app")?; self.write_dockerfile(dockerfile, &output) .context("Writing Dockerfile")?;