From 03a2f79561ba4a6cea516433d2004d76ee0d7896 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 18 Jan 2019 15:31:51 -0800 Subject: [PATCH] gateway: allow frontends without network Signed-off-by: Tonis Tiigi --- .../dockerfile/cmd/dockerfile-frontend/Dockerfile | 1 + frontend/gateway/gateway.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile b/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile index 8a56a934..348b38fc 100644 --- a/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile +++ b/frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile @@ -24,6 +24,7 @@ RUN --mount=target=. --mount=type=cache,target=/root/.cache \ file /dockerfile-frontend | grep "statically linked" FROM scratch AS release +LABEL moby.buildkit.frontend.network.none="true" COPY --from=build /dockerfile-frontend /bin/dockerfile-frontend ENTRYPOINT ["/bin/dockerfile-frontend"] diff --git a/frontend/gateway/gateway.go b/frontend/gateway/gateway.go index 266418f2..87e226a7 100644 --- a/frontend/gateway/gateway.go +++ b/frontend/gateway/gateway.go @@ -7,6 +7,7 @@ import ( "io" "net" "os" + "strconv" "strings" "sync" "time" @@ -193,12 +194,20 @@ func (gf *gatewayFrontend) Solve(ctx context.Context, llbBridge frontend.Fronten env = append(env, "BUILDKIT_EXPORTEDPRODUCT="+apicaps.ExportedProduct) - err = llbBridge.Exec(ctx, executor.Meta{ + meta := executor.Meta{ Env: env, Args: args, Cwd: cwd, ReadonlyRootFS: readonly, - }, rootFS, lbf.Stdin, lbf.Stdout, os.Stderr) + } + + if v, ok := img.Config.Labels["moby.buildkit.frontend.network.none"]; ok { + if ok, _ := strconv.ParseBool(v); ok { + meta.NetMode = opspb.NetMode_NONE + } + } + + err = llbBridge.Exec(ctx, meta, rootFS, lbf.Stdin, lbf.Stdout, os.Stderr) if err != nil { // An existing error (set via Return rpc) takes