Skip to content

Commit fadd8f5

Browse files
committed
bugfix: mount build cache directories (dirs were not created at host-side)
1 parent 46c4971 commit fadd8f5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cmd/bob/build.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ func runBuilder(builder bobfile.BuilderSpec, buildCtx *BuildContext, opDesc stri
7575
baseImageConf, err := loadNonOptionalBaseImageConf(buildCtx.Bobfile.ProjectName, builder)
7676
if err == nil { // it's optional here. used to mount the cache directories
7777
for _, pathContainer := range baseImageConf.PathsToCache {
78-
pathHostSide := makeCachePathHostSide(pathContainer)
78+
pathHostSide, err := makeCachePathHostSide(pathContainer)
79+
if err != nil {
80+
return err
81+
}
7982
buildArgs = append(buildArgs, fmt.Sprintf("--mount=type=bind,source=%s,destination=%s", pathHostSide, pathContainer))
8083
}
8184
}

cmd/bob/devshim.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,23 @@ func makeCacheDir(dir string) error {
221221
return err
222222
}
223223

224-
cacheCounterpart := makeCachePathHostSide(dir)
225-
226-
if err := os.MkdirAll(cacheCounterpart, 0755); err != nil {
224+
cacheCounterpart, err := makeCachePathHostSide(dir)
225+
if err != nil {
227226
return err
228227
}
229228

230229
return os.Symlink(cacheCounterpart, dir)
231230
}
232231

233232
// "/go/pkg" => "/tmp/build/go/pkg" (at host-side)
234-
func makeCachePathHostSide(pathInContainer string) string {
235-
return filepath.Join("/tmp/build/", pathInContainer)
233+
func makeCachePathHostSide(pathInContainer string) (string, error) {
234+
dir := filepath.Join("/tmp/build/", pathInContainer)
235+
236+
if err := os.MkdirAll(dir, 0755); err != nil {
237+
return "", err
238+
}
239+
240+
return dir, nil
236241
}
237242

238243
func readShimConfig() (*shimConfig, error) {

0 commit comments

Comments
 (0)