Просмотр исходного кода

local.compose.build: Ensure images are exported

If a user has BUILDX_NO_DEFAULT_LOAD=1 set, then the images will
not be stored in the image store unless we explicitly say that they
must be.

Signed-off-by: Chris Crone <[email protected]>
Chris Crone 4 лет назад
Родитель
Сommit
87153b9d25
2 измененных файлов с 3 добавлено и 0 удалено
  1. 1 0
      go.mod
  2. 2 0
      local/compose/build.go

+ 1 - 0
go.mod

@@ -38,6 +38,7 @@ require (
 	github.com/joho/godotenv v1.3.0
 	github.com/labstack/echo v3.3.10+incompatible
 	github.com/labstack/gommon v0.3.0 // indirect
+	github.com/moby/buildkit v0.8.1-0.20201205083753-0af7b1b9c693
 	github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf
 	github.com/morikuni/aec v1.0.0
 	github.com/opencontainers/go-digest v1.0.0

+ 2 - 0
local/compose/build.go

@@ -29,6 +29,7 @@ import (
 	_ "github.com/docker/buildx/driver/docker" // required to get default driver registered
 	"github.com/docker/buildx/util/progress"
 	"github.com/docker/docker/errdefs"
+	bclient "github.com/moby/buildkit/client"
 )
 
 func (s *composeService) Build(ctx context.Context, project *types.Project) error {
@@ -154,6 +155,7 @@ func (s *composeService) toBuildOptions(service types.ServiceConfig, contextPath
 		BuildArgs: flatten(mergeArgs(service.Build.Args, buildArgs)),
 		Tags:      tags,
 		Target:    service.Build.Target,
+		Exports:   []bclient.ExportEntry{{Type: "image", Attrs: map[string]string{}}},
 	}
 }