diff --git a/pkg/compiler/interface.go b/pkg/compiler/interface.go index 9dd2f8be..f504e5f7 100644 --- a/pkg/compiler/interface.go +++ b/pkg/compiler/interface.go @@ -45,4 +45,10 @@ type CompilationSpec interface { GetImage() string SetImage(string) + + SetOutputPath(string) + GetOutputPath() string + Rel(string) string + + GetPreBuildSteps() []string } diff --git a/pkg/compiler/spec.go b/pkg/compiler/spec.go index 932393e7..521eb764 100644 --- a/pkg/compiler/spec.go +++ b/pkg/compiler/spec.go @@ -16,16 +16,20 @@ package compiler import ( + "io/ioutil" + "path/filepath" + pkg "github.com/mudler/luet/pkg/package" yaml "gopkg.in/yaml.v2" - "io/ioutil" ) type LuetCompilationSpec struct { - Steps []string `json:"steps"` // Are run inside a container and the result layer diff is saved - Image string `json:"image"` - Seed string `json:"seed"` - Package pkg.Package `json:"-"` + Steps []string `json:"steps"` // Are run inside a container and the result layer diff is saved + PreBuildSteps []string `json:"pre_steps"` // Are run inside the image which will be our builder + Image string `json:"image"` + Seed string `json:"seed"` + Package pkg.Package `json:"-"` + OutputPath string `json:"-"` // Where the build processfiles go } func NewLuetCompilationSpec(b []byte, p pkg.Package) (CompilationSpec, error) { @@ -46,6 +50,10 @@ func (cs *LuetCompilationSpec) BuildSteps() []string { return cs.Steps } +func (cs *LuetCompilationSpec) GetPreBuildSteps() []string { + return cs.PreBuildSteps +} + func (cs *LuetCompilationSpec) GetSeedImage() string { return cs.Seed } @@ -69,6 +77,10 @@ FROM ` + cs.GetSeedImage() + ` COPY . /luetbuild WORKDIR /luetbuild ` + for _, s := range cs.GetPreBuildSteps() { + spec = spec + ` +RUN ` + s + } return spec, nil }