Skip to content

Commit 366fa6c

Browse files
committed
slight refactors, 127.0.0.1 -> localhost
localhost should be more portable; I have a vague notion of it being used for mapping networks to local Linux VMs and such (e.g. WSL), but don't know that it actually matters yet
1 parent 6d335e1 commit 366fa6c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

pkg/runtimes/buildkit.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os"
1212
"path"
1313
"path/filepath"
14+
"strconv"
1415
"strings"
1516
"sync"
1617
"text/tabwriter"
@@ -228,11 +229,7 @@ func (runtime *Buildkit) Start(ctx context.Context, thunk bass.Thunk) (PortInfos
228229
exited := make(chan error, 1)
229230
runs.Go(stop, func() error {
230231
exited <- runtime.Run(ctx, thunk)
231-
232-
// never fail; we don't really care whether services exit cleanly
233-
//
234-
// corresponds to _ = runs.Wait() elsewhere
235-
return nil
232+
return nil // disregard err; services don't have to exit cleanly
236233
})
237234

238235
ports := PortInfos{}
@@ -247,13 +244,20 @@ func (runtime *Buildkit) Start(ctx context.Context, thunk bass.Thunk) (PortInfos
247244
"port": bass.Int(port.Port),
248245
}.Scope()
249246

250-
pollAddr := fmt.Sprintf("127.0.0.1:%d", port.Port)
247+
pollAddr := net.JoinHostPort(host, strconv.Itoa(port.Port))
251248

252-
logger := zapctx.FromContext(ctx).
253-
With(zap.String("port", port.Name)).
254-
With(zap.String("addr", pollAddr))
249+
ctx, _ := zapctx.With(ctx,
250+
zap.String("port", port.Name),
251+
zap.String("addr", pollAddr))
255252

256-
err := pollForPort(zapctx.ToContext(ctx, logger), exited, port.Name, pollAddr)
253+
// TODO: this relies on the runtime being local to buildkit and able to
254+
// reach its host network
255+
//
256+
// does this work on Docker for Mac (and Windows)?
257+
//
258+
// it works on Linux with Docker, at least, and should work through Bass
259+
// Loop too since all the runtime code runs runner-side (phew)
260+
err := pollForPort(ctx, exited, port.Name, pollAddr)
257261
if err != nil {
258262
stop()
259263
return nil, err

0 commit comments

Comments
 (0)