Remove images from earlier deploys after a successful deploy (closes #216)
Check / check (pull_request) Skipped

After a successful deploy, upaas now removes the app's images other than
the one the running container uses and the previous one, which rollback
starts. Removing an image also removes the untagged images it was built on
unless another image still needs them. Images left by other stages of a
multi-stage build are not tied to the app and stay.

Model: opus-5-5
This commit is contained in:
2026-09-23 09:49:43 +00:00
parent ddcd179841
commit 4dbb654b79
5 changed files with 134 additions and 0 deletions
+25
View File
@@ -537,6 +537,31 @@ func (c *Client) RemoveImage(ctx context.Context, imageID ImageID) error {
return nil
}
// ListImageIDs returns the IDs of all images tagged in the given repository,
// such as "upaas-myapp".
func (c *Client) ListImageIDs(
ctx context.Context,
repository string,
) ([]ImageID, error) {
if c.docker == nil {
return nil, ErrNotConnected
}
images, err := c.docker.ImageList(ctx, image.ListOptions{
Filters: filters.NewArgs(filters.Arg("reference", repository)),
})
if err != nil {
return nil, fmt.Errorf("failed to list images: %w", err)
}
ids := make([]ImageID, 0, len(images))
for _, img := range images {
ids = append(ids, ImageID(img.ID))
}
return ids, nil
}
func (c *Client) performBuild(
ctx context.Context,
opts BuildImageOptions,