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 <christopher.crone@docker.com>
This commit is contained in:
Chris Crone 2020-12-11 11:08:44 +01:00
parent ddaec1a367
commit 87153b9d25
2 changed files with 3 additions and 0 deletions

1
go.mod
View File

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

View File

@ -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{}}},
}
}