@@ -26,8 +26,9 @@ import (
26
26
)
27
27
28
28
const (
29
- buildArgPrefix = "build-arg:"
30
- labelPrefix = "label:"
29
+ buildArgPrefix = "build-arg:"
30
+ labelPrefix = "label:"
31
+ localSessionIDPrefix = "local-sessionid:"
31
32
32
33
keyTarget = "target"
33
34
keyCgroupParent = "cgroup-parent"
@@ -79,10 +80,11 @@ type Config struct {
79
80
80
81
type Client struct {
81
82
Config
82
- client client.Client
83
- ignoreCache []string
84
- g flightcontrol.CachedGroup [* buildContext ]
85
- bopts client.BuildOpts
83
+ client client.Client
84
+ ignoreCache []string
85
+ g flightcontrol.CachedGroup [* buildContext ]
86
+ bopts client.BuildOpts
87
+ localsSessionIDs map [string ]string
86
88
87
89
dockerignore []byte
88
90
dockerignoreName string
@@ -298,6 +300,9 @@ func (bc *Client) init() error {
298
300
return errors .Wrapf (err , "failed to parse %s" , keyCopyIgnoredCheckEnabled )
299
301
}
300
302
}
303
+
304
+ bc .localsSessionIDs = parseLocalSessionIDs (opts )
305
+
301
306
return nil
302
307
}
303
308
@@ -331,9 +336,14 @@ func (bc *Client) ReadEntrypoint(ctx context.Context, lang string, opts ...llb.L
331
336
filenames = append (filenames , path .Join (path .Dir (bctx .filename ), strings .ToLower (DefaultDockerfileName )))
332
337
}
333
338
339
+ sessionID := bc .bopts .SessionID
340
+ if v , ok := bc .localsSessionIDs [bctx .dockerfileLocalName ]; ok {
341
+ sessionID = v
342
+ }
343
+
334
344
opts = append ([]llb.LocalOption {
335
345
llb .FollowPaths (filenames ),
336
- llb .SessionID (bc . bopts . SessionID ),
346
+ llb .SessionID (sessionID ),
337
347
llb .SharedKeyHint (bctx .dockerfileLocalName ),
338
348
WithInternalName (name ),
339
349
llb .Differ (llb .DiffNone , false ),
@@ -427,8 +437,13 @@ func (bc *Client) MainContext(ctx context.Context, opts ...llb.LocalOption) (*ll
427
437
return nil , errors .Wrapf (err , "failed to read dockerignore patterns" )
428
438
}
429
439
440
+ sessionID := bc .bopts .SessionID
441
+ if v , ok := bc .localsSessionIDs [bctx .contextLocalName ]; ok {
442
+ sessionID = v
443
+ }
444
+
430
445
opts = append ([]llb.LocalOption {
431
- llb .SessionID (bc . bopts . SessionID ),
446
+ llb .SessionID (sessionID ),
432
447
llb .ExcludePatterns (excludes ),
433
448
llb .SharedKeyHint (bctx .contextLocalName ),
434
449
WithInternalName ("load build context" ),
@@ -500,8 +515,12 @@ func WithInternalName(name string) llb.ConstraintsOpt {
500
515
501
516
func (bc * Client ) dockerIgnorePatterns (ctx context.Context , bctx * buildContext ) ([]string , error ) {
502
517
if bc .dockerignore == nil {
518
+ sessionID := bc .bopts .SessionID
519
+ if v , ok := bc .localsSessionIDs [bctx .contextLocalName ]; ok {
520
+ sessionID = v
521
+ }
503
522
st := llb .Local (bctx .contextLocalName ,
504
- llb .SessionID (bc . bopts . SessionID ),
523
+ llb .SessionID (sessionID ),
505
524
llb .FollowPaths ([]string {DefaultDockerignoreName }),
506
525
llb .SharedKeyHint (bctx .contextLocalName + "-" + DefaultDockerignoreName ),
507
526
WithInternalName ("load " + DefaultDockerignoreName ),
0 commit comments