Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -20,12 +20,18 @@ import ( |
| 20 | 20 |
"github.com/moby/buildkit/control" |
| 21 | 21 |
"github.com/moby/buildkit/identity" |
| 22 | 22 |
"github.com/moby/buildkit/session" |
| 23 |
+ "github.com/moby/buildkit/solver/llbsolver" |
|
| 24 |
+ "github.com/moby/buildkit/util/entitlements" |
|
| 23 | 25 |
"github.com/moby/buildkit/util/tracing" |
| 24 | 26 |
"github.com/pkg/errors" |
| 25 | 27 |
"golang.org/x/sync/errgroup" |
| 26 | 28 |
grpcmetadata "google.golang.org/grpc/metadata" |
| 27 | 29 |
) |
| 28 | 30 |
|
| 31 |
+func init() {
|
|
| 32 |
+ llbsolver.AllowNetworkHostUnstable = true |
|
| 33 |
+} |
|
| 34 |
+ |
|
| 29 | 35 |
// Opt is option struct required for creating the builder |
| 30 | 36 |
type Opt struct {
|
| 31 | 37 |
SessionManager *session.Manager |
| ... | ... |
@@ -230,6 +236,14 @@ func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder. |
| 230 | 230 |
frontendAttrs["platform"] = opt.Options.Platform |
| 231 | 231 |
} |
| 232 | 232 |
|
| 233 |
+ switch opt.Options.NetworkMode {
|
|
| 234 |
+ case "host", "none": |
|
| 235 |
+ frontendAttrs["force-network-mode"] = opt.Options.NetworkMode |
|
| 236 |
+ case "", "default": |
|
| 237 |
+ default: |
|
| 238 |
+ return nil, errors.Errorf("network mode %q not supported by buildkit", opt.Options.NetworkMode)
|
|
| 239 |
+ } |
|
| 240 |
+ |
|
| 233 | 241 |
exporterAttrs := map[string]string{}
|
| 234 | 242 |
|
| 235 | 243 |
if len(opt.Options.Tags) > 0 {
|
| ... | ... |
@@ -245,6 +259,10 @@ func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder. |
| 245 | 245 |
Session: opt.Options.SessionID, |
| 246 | 246 |
} |
| 247 | 247 |
|
| 248 |
+ if opt.Options.NetworkMode == "host" {
|
|
| 249 |
+ req.Entitlements = append(req.Entitlements, entitlements.EntitlementNetworkHost) |
|
| 250 |
+ } |
|
| 251 |
+ |
|
| 248 | 252 |
aux := streamformatter.AuxFormatter{Writer: opt.ProgressWriter.Output}
|
| 249 | 253 |
|
| 250 | 254 |
eg, ctx := errgroup.WithContext(ctx) |