Add PreBuild steps

They are executed when building the "builder" image, those are not accounted to the diffs when producing the final artifact
This commit is contained in:
Ettore Di Giacinto
2019-11-08 18:28:01 +01:00
parent 287212db1c
commit 0321973359
2 changed files with 23 additions and 5 deletions

View File

@@ -45,4 +45,10 @@ type CompilationSpec interface {
GetImage() string
SetImage(string)
SetOutputPath(string)
GetOutputPath() string
Rel(string) string
GetPreBuildSteps() []string
}

View File

@@ -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
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
}