Don't export unless needed

This commit is contained in:
Ettore Di Giacinto
2020-11-10 16:57:20 +01:00
parent 665261e526
commit 36c58307e2

View File

@@ -353,7 +353,7 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
return nil, errors.Wrap(err, "Failed building image for "+runnerOpts.ImageName+" "+runnerOpts.DockerFileName)
}
}
if generateArtifact {
if err := cs.Backend.ExportImage(runnerOpts); err != nil {
return nil, errors.Wrap(err, "Failed exporting image")
}
@@ -361,6 +361,7 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
if !cs.Options.KeepImageExport {
defer os.Remove(runnerOpts.Destination)
}
}
if cs.Options.Push && buildPackageImage {
err = cs.Backend.Push(runnerOpts)
@@ -378,6 +379,7 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
unpack = true
}
if generateArtifact {
rootfs, err := ioutil.TempDir(p.GetOutputPath(), "rootfs")
if err != nil {
return nil, errors.Wrap(err, "Could not create tempdir")
@@ -391,6 +393,7 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
if err != nil {
return nil, errors.Wrap(err, "Could not extract rootfs")
}
}
if !keepImg {
// We keep them around, so to not reload them from the tar (which should be the "correct way") and we automatically share the same layers