Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from tiborvass/18.06-vendor-buildkit
Browse files Browse the repository at this point in the history
[18.06] Set BuildKit's ExportedProduct variable to show useful errors in the future
  • Loading branch information
andrewhsu authored Aug 7, 2018
2 parents 5150e82 + 0832d1e commit 576e49d
Show file tree
Hide file tree
Showing 63 changed files with 4,036 additions and 1,516 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ DOCKER_ENVS := \
-e https_proxy \
-e no_proxy \
-e VERSION \
-e PLATFORM
-e PLATFORM \
-e PRODUCT
# note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds

# to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`
Expand Down
2 changes: 1 addition & 1 deletion builder/builder-next/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.
Session: opt.Options.SessionID,
}

aux := streamformatter.AuxFormatter{opt.ProgressWriter.Output}
aux := streamformatter.AuxFormatter{Writer: opt.ProgressWriter.Output}

eg, ctx := errgroup.WithContext(ctx)

Expand Down
29 changes: 13 additions & 16 deletions builder/builder-next/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (
"github.com/docker/docker/daemon/graphdriver"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/metadata"
"github.com/moby/buildkit/cache/remotecache"
registryremotecache "github.com/moby/buildkit/cache/remotecache/registry"
"github.com/moby/buildkit/control"
"github.com/moby/buildkit/exporter"
"github.com/moby/buildkit/frontend"
"github.com/moby/buildkit/frontend/dockerfile"
dockerfile "github.com/moby/buildkit/frontend/dockerfile/builder"
"github.com/moby/buildkit/frontend/gateway"
"github.com/moby/buildkit/frontend/gateway/forwarder"
"github.com/moby/buildkit/snapshot/blobmapping"
"github.com/moby/buildkit/solver/boltdbcachestorage"
"github.com/moby/buildkit/worker"
Expand Down Expand Up @@ -113,10 +114,6 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
return nil, err
}

frontends := map[string]frontend.Frontend{}
frontends["dockerfile.v0"] = dockerfile.NewDockerfileFrontend()
frontends["gateway.v0"] = gateway.NewGatewayFrontend()

wopt := mobyworker.Opt{
ID: "moby",
SessionManager: opt.SessionManager,
Expand All @@ -141,17 +138,17 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
}
wc.Add(w)

ci := remotecache.NewCacheImporter(remotecache.ImportOpt{
Worker: w,
SessionManager: opt.SessionManager,
})
frontends := map[string]frontend.Frontend{
"dockerfile.v0": forwarder.NewGatewayForwarder(wc, dockerfile.Build),
"gateway.v0": gateway.NewGatewayFrontend(wc),
}

return control.NewController(control.Opt{
SessionManager: opt.SessionManager,
WorkerController: wc,
Frontends: frontends,
CacheKeyStorage: cacheStorage,
// CacheExporter: ce,
CacheImporter: ci,
SessionManager: opt.SessionManager,
WorkerController: wc,
Frontends: frontends,
CacheKeyStorage: cacheStorage,
ResolveCacheImporterFunc: registryremotecache.ResolveCacheImporterFunc(opt.SessionManager),
// TODO: set ResolveCacheExporterFunc for exporting cache
})
}
2 changes: 1 addition & 1 deletion builder/builder-next/exporter/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, ref cache.ImmutableR
if ref != nil {
layersDone := oneOffProgress(ctx, "exporting layers")

if err := ref.Finalize(ctx); err != nil {
if err := ref.Finalize(ctx, true); err != nil {
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions builder/dockerfile/dispatchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ func TestFromWithArg(t *testing.T) {
args := NewBuildArgs(make(map[string]*string))

val := "sometag"
metaArg := instructions.ArgCommand{
metaArg := instructions.ArgCommand{KeyValuePairOptional: instructions.KeyValuePairOptional{
Key: "THETAG",
Value: &val,
}
}}
cmd := &instructions.Stage{
BaseName: "alpine:${THETAG}",
}
Expand Down Expand Up @@ -377,7 +377,7 @@ func TestArg(t *testing.T) {

argName := "foo"
argVal := "bar"
cmd := &instructions.ArgCommand{Key: argName, Value: &argVal}
cmd := &instructions.ArgCommand{KeyValuePairOptional: instructions.KeyValuePairOptional{Key: argName, Value: &argVal}}
err := dispatch(sb, cmd)
assert.NilError(t, err)

Expand Down
7 changes: 7 additions & 0 deletions cmd/dockerd/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/pkg/term"
"github.com/moby/buildkit/util/apicaps"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -42,6 +43,12 @@ func newDaemonCommand() *cobra.Command {
return cmd
}

func init() {
if dockerversion.ProductName != "" {
apicaps.ExportedProduct = dockerversion.ProductName
}
}

func main() {
if reexec.Init() {
return
Expand Down
1 change: 1 addition & 0 deletions dockerversion/version_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ const (
RuncCommitID = "library-import"
InitCommitID = "library-import"
PlatformName = ""
ProductName = ""
)
2 changes: 1 addition & 1 deletion hack/make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Try {
# Run autogen if building binaries or running unit tests.
if ($Client -or $Daemon -or $TestUnit) {
Write-Host "INFO: Invoking autogen..."
Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" }
Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" -Product "$env:PRODUCT" }
Catch [Exception] { Throw $_ }
}

Expand Down
1 change: 1 addition & 0 deletions hack/make/.go-autogen
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
IAmStatic string = "${IAMSTATIC:-true}"
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
PlatformName string = "${PLATFORM}"
ProductName string = "${PRODUCT}"
)
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
Expand Down
4 changes: 3 additions & 1 deletion hack/make/.go-autogen.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
param(
[Parameter(Mandatory=$true)][string]$CommitString,
[Parameter(Mandatory=$true)][string]$DockerVersion,
[Parameter(Mandatory=$false)][string]$Platform
[Parameter(Mandatory=$false)][string]$Platform,
[Parameter(Mandatory=$false)][string]$Product
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -45,6 +46,7 @@ const (
Version string = "'+$DockerVersion+'"
BuildTime string = "'+$buildDateTime+'"
PlatformName string = "'+$Platform+'"
ProductName string = "'+$Product+'"
)
// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1
Expand Down
2 changes: 1 addition & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ github.com/imdario/mergo v0.3.5
golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5

# buildkit
github.com/moby/buildkit 9acf51e49185b348608e0096b2903dd72907adcb
github.com/moby/buildkit 98f1604134f945d48538ffca0e18662337b4a850
github.com/tonistiigi/fsutil 8abad97ee3969cdf5e9c367f46adba2c212b3ddb
github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746
github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/moby/buildkit/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 576e49d

Please sign in to comment.