diff --git a/cmd/yb/build.go b/cmd/yb/build.go index 7a2b69db..bf9db158 100644 --- a/cmd/yb/build.go +++ b/cmd/yb/build.go @@ -193,7 +193,7 @@ func doTargetList(ctx context.Context, pkg *yb.Package, targets []*yb.BuildTarge } func doTarget(ctx context.Context, pkg *yb.Package, target *yb.BuildTarget, opts *doOptions) error { - bio, err := newBiome(ctx, newBiomeOptions{ + biomeOpts := newBiomeOptions{ packageDir: pkg.Path, target: target.Name, dataDirs: opts.dataDirs, @@ -201,7 +201,11 @@ func doTarget(ctx context.Context, pkg *yb.Package, target *yb.BuildTarget, opts dockerClient: opts.dockerClient, targetContainer: target.Container.ToNarwhal(), dockerNetworkID: opts.dockerNetworkID, - }) + } + if target.HostOnly { + biomeOpts = biomeOpts.disableDocker() + } + bio, err := newBiome(ctx, biomeOpts) if err != nil { return fmt.Errorf("target %s: %w", target.Name, err) } diff --git a/cmd/yb/helpers.go b/cmd/yb/helpers.go index f7872b31..5b8c3710 100644 --- a/cmd/yb/helpers.go +++ b/cmd/yb/helpers.go @@ -43,6 +43,14 @@ type newBiomeOptions struct { dockerNetworkID string } +func (opts newBiomeOptions) disableDocker() newBiomeOptions { + // Operating on copy, so free to modify fields. + opts.dockerClient = nil + opts.targetContainer = nil + opts.dockerNetworkID = "" + return opts +} + func newBiome(ctx context.Context, opts newBiomeOptions) (biome.BiomeCloser, error) { if opts.dockerClient == nil { l := biome.Local{ diff --git a/cmd/yb/run.go b/cmd/yb/run.go index 1de58398..59346ecf 100644 --- a/cmd/yb/run.go +++ b/cmd/yb/run.go @@ -78,7 +78,7 @@ func (b *runCmd) run(ctx context.Context, args []string) error { // Run command. execTarget := targets[len(targets)-1] - bio, err := newBiome(ctx, newBiomeOptions{ + biomeOpts := newBiomeOptions{ packageDir: pkg.Path, target: execTarget.Name, dataDirs: dataDirs, @@ -86,7 +86,11 @@ func (b *runCmd) run(ctx context.Context, args []string) error { dockerClient: dockerClient, targetContainer: execTarget.Container.ToNarwhal(), dockerNetworkID: dockerNetworkID, - }) + } + if execTarget.HostOnly { + biomeOpts = biomeOpts.disableDocker() + } + bio, err := newBiome(ctx, biomeOpts) if err != nil { return err }