@@ -11,6 +11,7 @@ import (
11
11
"os"
12
12
"os/user"
13
13
"path/filepath"
14
+ "runtime"
14
15
"sort"
15
16
"strconv"
16
17
"strings"
@@ -20,6 +21,7 @@ import (
20
21
"github.com/spf13/pflag"
21
22
"github.com/yourbase/yb"
22
23
"github.com/yourbase/yb/internal/biome"
24
+ "github.com/yourbase/yb/internal/build"
23
25
"github.com/yourbase/yb/internal/config"
24
26
"github.com/yourbase/yb/internal/ybdata"
25
27
"zombiezen.com/go/log"
@@ -249,7 +251,7 @@ func newDockerNetwork(ctx context.Context, client *docker.Client, mode execution
249
251
}
250
252
251
253
func showDockerWarningsIfNeeded (ctx context.Context , mode executionMode , targets []* yb.Target ) {
252
- if ! willUseDocker (mode , targets ) {
254
+ if ! willUseDocker (mode , targets ) || runtime . GOOS != biome . Linux {
253
255
return
254
256
}
255
257
dockerGroup , err := user .LookupGroup ("docker" )
@@ -281,8 +283,10 @@ func showDockerWarningsIfNeeded(ctx context.Context, mode executionMode, targets
281
283
282
284
func willUseDocker (mode executionMode , targets []* yb.Target ) bool {
283
285
for _ , target := range targets {
284
- if len (target .Resources ) > 0 {
285
- return true
286
+ for name := range target .Resources {
287
+ if os .Getenv (build .ContainerIPEnvVar (name )) == "" {
288
+ return true
289
+ }
286
290
}
287
291
}
288
292
return willUseDockerForCommands (mode , targets )
@@ -291,10 +295,14 @@ func willUseDocker(mode executionMode, targets []*yb.Target) bool {
291
295
func willUseDockerForCommands (mode executionMode , targets []* yb.Target ) bool {
292
296
networkAvailable , _ := hostHasDockerNetwork ()
293
297
for _ , target := range targets {
294
- if target .UseContainer ||
295
- len (target .Resources ) > 0 && ! networkAvailable {
298
+ if target .UseContainer {
296
299
return true
297
300
}
301
+ for name := range target .Resources {
302
+ if os .Getenv (build .ContainerIPEnvVar (name )) == "" && ! networkAvailable {
303
+ return true
304
+ }
305
+ }
298
306
}
299
307
return mode >= useContainer
300
308
}
0 commit comments