Skip to content

Commit

Permalink
Merge pull request #151 from suborbital/jagger/bundle-panic
Browse files Browse the repository at this point in the history
Fix subo build --docker segfaults
  • Loading branch information
Jagger De Leo authored Dec 9, 2021
2 parents c556ae3 + 6057a6a commit e6edcff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions subo/command/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func BuildCmd() *cobra.Command {
}

if len(bdr.Context.Runnables) == 0 {
return errors.New("🚫 no runnables found in current directory (no .runnable yaml files found)")
return errors.New("🚫 no runnables found in current directory (no .runnable.yaml files found)")
}

if bdr.Context.CwdIsRunnable {
Expand All @@ -42,6 +42,10 @@ func BuildCmd() *cobra.Command {
shouldBundle := !noBundle && !bdr.Context.CwdIsRunnable && len(langs) == 0
shouldDockerBuild, _ := cmd.Flags().GetBool("docker")

if bdr.Context.CwdIsRunnable && shouldDockerBuild {
return errors.New("🚫 cannot build Docker image for a single Runnable (must be a project)")
}

useNative, _ := cmd.Flags().GetBool("native")
makeTarget, _ := cmd.Flags().GetString("make")

Expand Down Expand Up @@ -94,7 +98,11 @@ func BuildCmd() *cobra.Command {
defer util.LogDone(fmt.Sprintf("bundle was created -> %s @ %s", bdr.Context.Bundle.Fullpath, bdr.Context.Directive.AppVersion))
}

if shouldDockerBuild {
if shouldDockerBuild && !bdr.Context.CwdIsRunnable {
if bdr.Context.Directive == nil {
return errors.New("🚫 failed to open Directive.yaml")
}

os.Setenv("DOCKER_BUILDKIT", "0")

if _, err := util.Run(fmt.Sprintf("docker build . -t=%s:%s", bdr.Context.Directive.Identifier, bdr.Context.Directive.AppVersion)); err != nil {
Expand Down

0 comments on commit e6edcff

Please sign in to comment.