mirror of
https://github.com/ko-build/ko.git
synced 2024-12-12 08:54:09 +02:00
parent
d32f069b69
commit
f46a2b6372
@ -290,7 +290,7 @@ func (gb *gobuild) Build(s string) (v1.Image, error) {
|
||||
}
|
||||
defer os.RemoveAll(filepath.Dir(file))
|
||||
|
||||
var layers []v1.Layer
|
||||
var layers []mutate.Addendum
|
||||
// Create a layer from the kodata directory under this import path.
|
||||
dataLayerBuf, err := tarKoData(s)
|
||||
if err != nil {
|
||||
@ -303,7 +303,14 @@ func (gb *gobuild) Build(s string) (v1.Image, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
layers = append(layers, dataLayer)
|
||||
layers = append(layers, mutate.Addendum{
|
||||
Layer: dataLayer,
|
||||
History: v1.History{
|
||||
Author: "ko",
|
||||
CreatedBy: "ko publish " + s,
|
||||
Comment: "kodata contents, at $KO_DATA_PATH",
|
||||
},
|
||||
})
|
||||
|
||||
appPath := filepath.Join(appDir, appFilename(s))
|
||||
|
||||
@ -319,7 +326,14 @@ func (gb *gobuild) Build(s string) (v1.Image, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
layers = append(layers, binaryLayer)
|
||||
layers = append(layers, mutate.Addendum{
|
||||
Layer: binaryLayer,
|
||||
History: v1.History{
|
||||
Author: "ko",
|
||||
CreatedBy: "ko publish " + s,
|
||||
Comment: "go build output, at " + appPath,
|
||||
},
|
||||
})
|
||||
|
||||
// Determine the appropriate base image for this import path.
|
||||
base, err := gb.getBase(s)
|
||||
@ -328,7 +342,7 @@ func (gb *gobuild) Build(s string) (v1.Image, error) {
|
||||
}
|
||||
|
||||
// Augment the base image with our application layer.
|
||||
withApp, err := mutate.AppendLayers(base, layers...)
|
||||
withApp, err := mutate.Append(base, layers...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -343,8 +357,10 @@ func (gb *gobuild) Build(s string) (v1.Image, error) {
|
||||
cfg = cfg.DeepCopy()
|
||||
cfg.Config.Entrypoint = []string{appPath}
|
||||
cfg.Config.Env = append(cfg.Config.Env, "KO_DATA_PATH="+kodataRoot)
|
||||
cfg.ContainerConfig = cfg.Config
|
||||
cfg.Author = "github.com/google/ko"
|
||||
|
||||
image, err := mutate.Config(withApp, cfg.Config)
|
||||
image, err := mutate.ConfigFile(withApp, cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user