Skip to content
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
8 changes: 7 additions & 1 deletion pkg/build/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func resolveStates(ctx context.Context, bopts *BOpts, platform ocispecs.Platform
states := map[string]stateMeta{}
stateLock := sync.Mutex{}

for _, stage := range stages {
for i, stage := range stages {
wg.Add(1)
go func(stage instructions.Stage) {
defer wg.Done()
Expand All @@ -145,6 +145,12 @@ func resolveStates(ctx context.Context, bopts *BOpts, platform ocispecs.Platform
return
}

// if there's another stage with this name before the current stage, that will be used as the source
namedIndex, hasNamedStage := instructions.HasStage(stages, resolvedBaseStageName.Result)
if hasNamedStage && namedIndex < i {
return
}

ref, err := dref.ParseAnyReference(resolvedBaseStageName.Result)
if err != nil {
if err == reference.ErrObjectRequired {
Expand Down
Loading