Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix [#255]: deletes downloaded image afterwards #259

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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