@@ -20,12 +20,10 @@ import (
2020 "bytes"
2121 "context"
2222 "encoding/base64"
23- "fmt"
2423 "path/filepath"
2524 "strings"
2625
2726 "github.com/containerd/platforms"
28- "github.com/google/uuid"
2927 "github.com/moby/buildkit/frontend/dockerfile/instructions"
3028 "github.com/moby/buildkit/frontend/dockerfile/parser"
3129 "github.com/moby/buildkit/util/progress/progresswriter"
@@ -43,8 +41,9 @@ const (
4341 KeyContentStoreName = "container"
4442 // Base64-encoded Dockerfile contents.
4543 KeyDockerfile = "dockerfile"
46- // Base64-encoded docker specific ignore file contents.
47- KeyDockerignore = "dockerignore"
44+ // Hidden directory for the dockerfile to be placed.
45+ // Used when docker specific ignore file is found.
46+ KeyHiddenDockerDir = "hidden-docker-dir"
4847 // Image reference (name:tag) to assign to the built image.
4948 KeyTag = "tag"
5049 // Target platforms to build the image for.
@@ -78,21 +77,21 @@ const (
7877var keyBOpts = struct {}{}
7978
8079type BOpts struct {
81- BuildID string
82- Dockerfile []byte
83- Tag string
84- ContextDir string
85- HiddenDirName string
86- BuildPlatforms []ocispecs.Platform
87- Platforms []ocispecs.Platform
88- NoCache bool
89- Target string
90- BuildArgs map [string ]string
91- CacheIn []string
92- CacheOut []string
93- Outputs []string
94- Labels map [string ]string
95- ProgressWriter progresswriter.Writer
80+ BuildID string
81+ Dockerfile []byte
82+ Tag string
83+ ContextDir string
84+ HiddenDockerDir string
85+ BuildPlatforms []ocispecs.Platform
86+ Platforms []ocispecs.Platform
87+ NoCache bool
88+ Target string
89+ BuildArgs map [string ]string
90+ CacheIn []string
91+ CacheOut []string
92+ Outputs []string
93+ Labels map [string ]string
94+ ProgressWriter progresswriter.Writer
9695
9796 ContentStore * content.ContentStoreProxy
9897 Resolver * resolver.ResolverProxy
@@ -126,19 +125,7 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
126125 return nil , err
127126 }
128127
129- var dockerignoreBytes = []byte (nil )
130- var hiddenDirName = ""
131-
132- dockerignoreBase64Bytes , ok := first (KeyDockerignore )
133- if ok {
134- dockerignoreBytes , err = base64 .StdEncoding .DecodeString (dockerignoreBase64Bytes )
135- if err != nil {
136- return nil , err
137- }
138-
139- hiddenDirName = ".tmp-" + uuid .NewString ()
140- dockerignoreBytes = append (dockerignoreBytes , fmt .Sprintf ("\n %s" , hiddenDirName )... )
141- }
128+ hiddenDockerDir , _ := first (KeyHiddenDockerDir )
142129
143130 progress , ok := first (KeyProgress )
144131 if ! ok {
@@ -278,7 +265,7 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
278265 }
279266 }
280267
281- fssyncProxy , err := fssync .NewFSSyncProxy ("." , basePath , hiddenDirName , dockerfileBytes , dockerignoreBytes , addedGlobs )
268+ fssyncProxy , err := fssync .NewFSSyncProxy ("." , basePath , addedGlobs )
282269 if err != nil {
283270 return nil , err
284271 }
@@ -289,26 +276,26 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
289276 }
290277
291278 bopts := & BOpts {
292- BuildID : buildID ,
293- Dockerfile : dockerfileBytes ,
294- Tag : tag ,
295- BuildPlatforms : bps ,
296- Platforms : pls ,
297- ContextDir : ctxDir ,
298- HiddenDirName : hiddenDirName ,
299- ContentStore : contentProxy ,
300- FSSync : fssyncProxy ,
301- NoCache : noCache ,
302- Resolver : resolver .NewResolverProxy (),
303- ProgressWriter : pw ,
304- Stdio : stdioProxy ,
305- Target : target ,
306- Labels : labels ,
307- BuildArgs : buildArgs ,
308- CacheIn : cacheIn ,
309- CacheOut : cacheOut ,
310- Outputs : outputs ,
311- basePath : filepath .Join (basePath , buildID ),
279+ BuildID : buildID ,
280+ Dockerfile : dockerfileBytes ,
281+ Tag : tag ,
282+ BuildPlatforms : bps ,
283+ Platforms : pls ,
284+ ContextDir : ctxDir ,
285+ HiddenDockerDir : hiddenDockerDir ,
286+ ContentStore : contentProxy ,
287+ FSSync : fssyncProxy ,
288+ NoCache : noCache ,
289+ Resolver : resolver .NewResolverProxy (),
290+ ProgressWriter : pw ,
291+ Stdio : stdioProxy ,
292+ Target : target ,
293+ Labels : labels ,
294+ BuildArgs : buildArgs ,
295+ CacheIn : cacheIn ,
296+ CacheOut : cacheOut ,
297+ Outputs : outputs ,
298+ basePath : filepath .Join (basePath , buildID ),
312299 }
313300
314301 return bopts , nil
0 commit comments