Skip to content

Commit

Permalink
deletes downloaded image afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
taukakao authored and mirkobrombin committed Apr 19, 2024
1 parent 28f40b5 commit ffd2688
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir s
return err
}

pulledImage := false
// pull image
if !strings.HasPrefix(imageRecipe.From, "localhost/") {
err = pullImageWithProgressbar(pt, buildImageName, imageRecipe)
if err != nil {
PrintVerboseErr("OciExportRootFs", 6.1, err)
return err
}
pulledImage = true
}

// build image
Expand All @@ -94,6 +96,15 @@ func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir s
return err
}

if pulledImage {
// This is safe because BuildContainerFile layers on top of the base image
// So this won't delete the actual layers, only the image reference
_, err = pt.Store.DeleteImage(imageRecipe.From, true)
if err != nil {
PrintVerboseWarn("OciExportRootFs", 7.5, "could not delete downloaded image", err)
}
}

// mount image
mountDir, err := pt.MountImage(imageBuild.TopLayer)
if err != nil {
Expand Down

0 comments on commit ffd2688

Please sign in to comment.