mirror of
https://github.com/mudler/luet.git
synced 2025-09-01 23:37:07 +00:00
Add CreateTar to image API
Add api call which uses go-container registry to create OCI images from standard tar archives. Consume new API when generating final images instead of docker building them and adapts/add tests as necessary. This change now allows to carry over xattrs to final images. Fixes #266
This commit is contained in:
@@ -26,6 +26,7 @@ func NewBackend(ctx *types.Context, s string) (CompilerBackend, error) {
|
||||
type CompilerBackend interface {
|
||||
BuildImage(backend.Options) error
|
||||
ExportImage(backend.Options) error
|
||||
LoadImage(string) error
|
||||
RemoveImage(backend.Options) error
|
||||
ImageDefinitionToTar(backend.Options) error
|
||||
|
||||
|
@@ -71,6 +71,17 @@ func (s *SimpleDocker) CopyImage(src, dst string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SimpleDocker) LoadImage(path string) error {
|
||||
s.ctx.Debug(":whale: Loading image:", path)
|
||||
cmd := exec.Command("docker", "load", "-i", path)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed loading image: "+string(out))
|
||||
}
|
||||
s.ctx.Success(":whale: Loaded image:", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SimpleDocker) DownloadImage(opts Options) error {
|
||||
name := opts.ImageName
|
||||
bus.Manager.Publish(bus.EventImagePrePull, opts)
|
||||
|
@@ -35,6 +35,10 @@ func NewSimpleImgBackend(ctx *types.Context) *SimpleImg {
|
||||
return &SimpleImg{ctx: ctx}
|
||||
}
|
||||
|
||||
func (s *SimpleImg) LoadImage(string) error {
|
||||
return errors.New("Not supported")
|
||||
}
|
||||
|
||||
// TODO: Missing still: labels, and build args expansion
|
||||
func (s *SimpleImg) BuildImage(opts Options) error {
|
||||
name := opts.ImageName
|
||||
|
@@ -962,14 +962,14 @@ func (cs *LuetCompiler) resolveFinalImages(concurrency int, keepPermissions bool
|
||||
|
||||
joinImageName := fmt.Sprintf("%s:%s", cs.Options.PushImageRepository, overallFp)
|
||||
cs.Options.Context.Info(joinTag, ":droplet: generating image from artifact", joinImageName)
|
||||
opts, err := a.GenerateFinalImage(cs.Options.Context, joinImageName, cs.Backend, keepPermissions)
|
||||
err = a.GenerateFinalImage(cs.Options.Context, joinImageName, cs.Backend, keepPermissions)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not create final image")
|
||||
}
|
||||
if cs.Options.Push {
|
||||
cs.Options.Context.Info(joinTag, ":droplet: pushing image from artifact", joinImageName)
|
||||
if err = cs.Backend.Push(opts); err != nil {
|
||||
return errors.Wrapf(err, "Could not push image: %s %s", image, opts.DockerFileName)
|
||||
if err = cs.Backend.Push(backend.Options{ImageName: joinImageName}); err != nil {
|
||||
return errors.Wrapf(err, "Could not push image: %s", joinImageName)
|
||||
}
|
||||
}
|
||||
cs.Options.Context.Info(joinTag, ":droplet: Consuming image", joinImageName)
|
||||
|
Reference in New Issue
Block a user