dockerfile: detect empty images early
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>docker-18.09
parent
8084e8cde9
commit
eefc49ff72
|
@ -156,6 +156,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
|
|||
return err
|
||||
}
|
||||
d.stage.BaseName = reference.TagNameOnly(ref).String()
|
||||
var isScratch bool
|
||||
if metaResolver != nil && reachable {
|
||||
dgst, dt, err := metaResolver.ResolveImageConfig(ctx, d.stage.BaseName)
|
||||
if err == nil { // handle the error while builder is actually running
|
||||
|
@ -173,9 +174,16 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
|
|||
}
|
||||
d.stage.BaseName = ref.String()
|
||||
_ = ref
|
||||
if len(img.RootFS.DiffIDs) == 0 {
|
||||
isScratch = true
|
||||
}
|
||||
}
|
||||
}
|
||||
d.state = llb.Image(d.stage.BaseName, dfCmd(d.stage.SourceCode))
|
||||
if isScratch {
|
||||
d.state = llb.Scratch()
|
||||
} else {
|
||||
d.state = llb.Image(d.stage.BaseName, dfCmd(d.stage.SourceCode))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}(i, d)
|
||||
|
|
|
@ -88,8 +88,10 @@ func (b *llbBridge) Solve(ctx context.Context, req frontend.SolveRequest) (res s
|
|||
if !ok {
|
||||
return nil, nil, errors.Errorf("invalid reference for exporting: %T", res.Sys())
|
||||
}
|
||||
if err := wr.ImmutableRef.Finalize(ctx); err != nil {
|
||||
return nil, nil, err
|
||||
if wr.ImmutableRef != nil {
|
||||
if err := wr.ImmutableRef.Finalize(ctx); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue