Moving dep builds into Dockerfile and multi-stage builds.

This commit is contained in:
Travis Reeder
2017-06-06 15:02:08 -07:00
committed by Denis Makogon
parent 0276a1c156
commit f628e39490
17 changed files with 268 additions and 226 deletions

View File

@@ -36,6 +36,16 @@ func GetLangHelper(lang string) LangHelper {
}
type LangHelper interface {
// BuildFromImage is the base image to build off, typically funcy/LANG:dev
BuildFromImage() string
// RunFromImage is the base image to use for deployment (usually smaller than the build images)
RunFromImage() string
// If set to false, it will use a single Docker build step, rather than multi-stage
IsMultiStage() bool
// Dockerfile build lines for building dependencies or anything else language specific
DockerfileBuildCmds() []string
// DockerfileCopyCmds will run in second/final stage of multi-stage build to copy artifacts form the build stage
DockerfileCopyCmds() []string
// Entrypoint sets the Docker Entrypoint. One of Entrypoint or Cmd is required.
Entrypoint() string
// Cmd sets the Docker command. One of Entrypoint or Cmd is required.
@@ -54,10 +64,19 @@ type LangHelper interface {
type BaseHelper struct {
}
func (h *BaseHelper) Cmd() string { return "" }
func (h *BaseHelper) HasBoilerplate() bool { return false }
func (h *BaseHelper) GenerateBoilerplate() error { return nil }
func (h *BaseHelper) BuildFromImage() string { return "" }
func (h *BaseHelper) RunFromImage() string { return h.BuildFromImage() }
func (h *BaseHelper) IsMultiStage() bool { return true }
func (h *BaseHelper) DockerfileBuildCmds() []string { return []string{} }
func (h *BaseHelper) DockerfileCopyCmds() []string { return []string{} }
func (h *BaseHelper) Cmd() string { return "" }
func (lh *BaseHelper) HasPreBuild() bool { return false }
func (lh *BaseHelper) PreBuild() error { return nil }
func (lh *BaseHelper) AfterBuild() error { return nil }
func (h *BaseHelper) HasBoilerplate() bool { return false }
func (h *BaseHelper) GenerateBoilerplate() error { return nil }
// exists checks if a file exists
func exists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {