Skip to content

Commit

Permalink
Error if no start phase or start command (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup authored Sep 14, 2022
1 parent 04f3c68 commit 11d87b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)?;
Expand Down
5 changes: 5 additions & 0 deletions src/nixpacks/builder/docker/docker_image_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand Down

0 comments on commit 11d87b4

Please sign in to comment.