gateway: allow frontends without network

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-19.03
Tonis Tiigi 2019-01-18 15:31:51 -08:00
parent c5fe22fffe
commit 03a2f79561
2 changed files with 12 additions and 2 deletions

View File

@ -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"]

View File

@ -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