mirror of
https://github.com/labring/sealos.git
synced 2026-09-24 15:46:19 +08:00
feature(main): fix images build (#945)
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fanux/sealos/pkg/buildimage"
|
||||
"github.com/fanux/sealos/pkg/registry"
|
||||
@@ -112,20 +111,17 @@ func inspectImage(data string) (*v1.Image, error) {
|
||||
func (d *ImageService) Build(options *types.BuildOptions, contextDir, imageName string) error {
|
||||
//contants.ImageShimDirName
|
||||
imageFetchDir := path.Join(contextDir, contants.ManifestsDirName)
|
||||
images, err := buildimage.ParseYamlImages(imageFetchDir)
|
||||
logger.Info("fetch manifests images: %v", images)
|
||||
yamlImages, err := buildimage.ParseYamlImages(imageFetchDir)
|
||||
logger.Info("fetch manifests images: %v", yamlImages)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get images list failed in this context")
|
||||
}
|
||||
imageListDir := path.Join(contextDir, contants.ImagesDirName, contants.ImageShimDirName)
|
||||
imageListFile := path.Join(imageListDir, fmt.Sprintf("ImageList_%d", time.Now().Unix()))
|
||||
if err = fileutil.WriteLines(imageListFile, images); err != nil {
|
||||
return errors.Wrap(err, "write images list failed in this context")
|
||||
}
|
||||
images, err = buildimage.LoadImages(imageListDir)
|
||||
images, err := buildimage.LoadImages(imageListDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "load images list failed in this context")
|
||||
}
|
||||
images = append(images, yamlImages...)
|
||||
//TODO add auth
|
||||
is := registry.NewImageSaver(context.Background(), nil)
|
||||
platform := strings.Split(options.Platform, "/")
|
||||
@@ -149,10 +145,6 @@ func (d *ImageService) Build(options *types.BuildOptions, contextDir, imageName
|
||||
return errors.Wrap(err, "save images failed in this context")
|
||||
}
|
||||
logger.Info("output images %v for platform is %s", images, strings.Join([]string{platformVar.OS, platformVar.Architecture}, "/"))
|
||||
fileutil.CleanDir(imageListDir)
|
||||
if err = fileutil.WriteLines(imageListFile, images); err != nil {
|
||||
return errors.Wrap(err, "write out images list failed in this context")
|
||||
}
|
||||
options.Tag = imageName
|
||||
cmd := fmt.Sprintf("buildah build %s %s", options.String(), contextDir)
|
||||
return exec.Cmd("bash", "-c", cmd)
|
||||
|
||||
Reference in New Issue
Block a user