Skip to content

Commit

Permalink
feat(build): publish custom tags and final images in parallel
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
  • Loading branch information
alexey-igrychev committed May 22, 2024
1 parent f78f78f commit ff2843a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/build/build_phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/werf/werf/v2/pkg/storage"
"github.com/werf/werf/v2/pkg/storage/manager"
"github.com/werf/werf/v2/pkg/util"
"github.com/werf/werf/v2/pkg/util/parallel"
"github.com/werf/werf/v2/pkg/werf"
)

Expand Down Expand Up @@ -197,8 +198,13 @@ func (phase *BuildPhase) AfterImages(ctx context.Context) error {
commonTargetPlatforms = []string{phase.Conveyor.ContainerBackend.GetDefaultPlatform()}
}

for _, desc := range phase.Conveyor.imagesTree.GetImagesByName(false) {
name, images := desc.Unpair()
imagesPairs := phase.Conveyor.imagesTree.GetImagesByName(false)
if err := parallel.DoTasks(ctx, len(imagesPairs), parallel.DoTasksOptions{
MaxNumberOfWorkers: phase.Conveyor.StorageManager.MaxNumberOfWorkers(),
}, func(ctx context.Context, taskId int) error {
pair := imagesPairs[taskId]

name, images := pair.Unpair()
platforms := util.MapFuncToSlice(images, func(img *image.Image) string { return img.TargetPlatform })

// TODO: this target platforms assertion could be removed in future versions and now exists only as a additional self-testing code
Expand Down Expand Up @@ -289,6 +295,10 @@ func (phase *BuildPhase) AfterImages(ctx context.Context) error {
}
}
}

return nil
}); err != nil {
return err
}

return phase.createReport(ctx)
Expand Down

0 comments on commit ff2843a

Please sign in to comment.