Skip to content

Commit

Permalink
feat: add korin.DockerBuildStep for properly using Korin as a Docke…
Browse files Browse the repository at this point in the history
…r build step
  • Loading branch information
ShindouMihou committed Jan 4, 2025
1 parent 2b3fcba commit f76b318
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/korin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import "github.com/ShindouMihou/korin/pkg/korin"

func main() {
korin := korin.New()

// You should use this when building a Docker image.
// korin.DockerBuildStep("examples/")

korin.Run("examples/sample.go")
}
10 changes: 10 additions & 0 deletions pkg/korin/external_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ func (ko Korin) Build(dir string) {
}
}

// DockerBuildStep is a synonymous function to `Build` but is specifically for Docker builds,
// as this will exit the program with `os.Exit(1)` which will signify to Docker that the
// build step failed.
func (ko Korin) DockerBuildStep(dir string) {
errs := ko.Process(dir)
if !ko.handle(errs) {
os.Exit(1)
}
}

// BuildRootDirectory builds the root directory (which is "." directory of the project)
func (ko Korin) BuildRootDirectory() {
ko.Build(".")
Expand Down

0 comments on commit f76b318

Please sign in to comment.