Migrate to go mod#800
Conversation
| @@ -0,0 +1,83 @@ | |||
| module github.com/moby/buildkit | |||
|
|
|||
| go 1.12 | |||
There was a problem hiding this comment.
TODO: verify that this doesn't cause issues with go1.11
Could you be more specific? Are we also going to migrate moby/moby (and containerd? runc?) to go mod soon? |
|
@tiborvass Also need to update the vendor validation/update scripts. And CI does not pass. |
Signed-off-by: Tibor Vass <tibor@docker.com>
|
@AkihiroSuda Updated the description. Ideally I'd like to convert everything to go mod, but I wanted to start with buildkit to see how it goes. |
4527e79 to
b12a6f4
Compare
| github.com/docker/go-events v0.0.0-20170721190031-9461782956ad // indirect | ||
| github.com/docker/go-units v0.3.1 // indirect | ||
| github.com/docker/libnetwork v0.0.0-20180913200009-36d3bed0e9f4 | ||
| github.com/godbus/dbus v4.1.0+incompatible // indirect |
There was a problem hiding this comment.
The +incompatible just means that even though the repo is using semver v2+, it doesn't have a go.mod, so go is precautious and treats it as v0 (aka things can break when it updates).
|
The go version in go.mod is simply metadata and is not yet used to inform any decisions. Here is the commit golang/go@16962fa |
| iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX) | ||
| docker build --build-arg VNDR_VERSION=1fc68ee0c852556a9ed53cbde16247033f104111 --iidfile $iidfile -f ./hack/dockerfiles/vendor.Dockerfile --force-rm . | ||
| dockerfile=vendor.Dockerfile | ||
| if [ "$buildmode" == "docker-buildkit" ]; then |
There was a problem hiding this comment.
still support buildkit mode even if it runs docker
| RUN --mount=target=. --mount=type=cache,target=/root/.cache \ | ||
| --mount=source=/tmp/.ldflags,target=/tmp/.ldflags,from=version \ | ||
| CGO_ENABLED=0 go build -o /dockerfile-frontend -ldflags "-d $(cat /tmp/.ldflags)" -tags "$BUILDTAGS netgo static_build osusergo" ./frontend/dockerfile/cmd/dockerfile-frontend && \ | ||
| CGO_ENABLED=0 GO111MODULE=on go build -mod vendor -o /dockerfile-frontend -ldflags "-d $(cat /tmp/.ldflags)" -tags "$BUILDTAGS netgo static_build osusergo" ./frontend/dockerfile/cmd/dockerfile-frontend && \ |
There was a problem hiding this comment.
Will this change in go1.12 ? If the dockerfiles don't use go mod anyway atm we don't need -mod vendor. We could just add comments with a reminder that we need to enable it when go mod is enabled.
ed84a89 to
9c3d761
Compare
| @@ -1,3 +1,5 @@ | |||
| # syntax = docker/dockerfile:1.0-experimental | |||
| FROM buildkit-base AS buildctl | ||
| ENV CGO_ENABLED=0 | ||
| RUN go build -ldflags "$(cat .tmp/ldflags) -d" -o /usr/bin/buildctl ./cmd/buildctl | ||
| RUN go build -mod vendor -ldflags "$(cat .tmp/ldflags) -d" -o /usr/bin/buildctl ./cmd/buildctl |
There was a problem hiding this comment.
I think I prefer GOFLAGS=-mod=vendor although that is easier to break.
| COPY --from=vendored /out /out | ||
|
|
||
| FROM vendored AS validate | ||
| RUN --mount=target=.,rw \ |
There was a problem hiding this comment.
$ touch vendor/toto
$ ./hack/validate-vendor
It should fail in that case. If I add rm -rf vendor it will not fail.
There was a problem hiding this comment.
removing the file should cause the status --porcelain to fail then.
There was a problem hiding this comment.
It doesn't because status --porcelain is run after we "cleaned" vendor.
There was a problem hiding this comment.
Fine, you win. It doesn't validate correctly if I commit vendor/toto. I need to add git add -A like in generated-files' dockerfile to cover my less useful usecase.
| --frontend-opt target=update \ | ||
| --frontend-opt filename=./hack/dockerfiles/vendor.buildkit.Dockerfile \ | ||
| --exporter=local --exporter-opt output=$output | ||
| cp -R "$output/out/" . |
| # Remove vendor first to workaround https://github.com/LK4D4/vndr/issues/63. | ||
| RUN rm -rf vendor | ||
| RUN vndr --verbose --strict | ||
| RUN go mod tidy && go mod vendor && rm -rf /go/pkg/mod |
There was a problem hiding this comment.
How does this work? Doesn't hack script expect files in /out ?
a34695d to
e3f0da2
Compare
|
ping @AkihiroSuda |
|
I'm exploring an issue when upgrading fsutil with |
|
From
|
|
Found some issues where validate vendor passes with a dirty |
|
@tonistiigi fixed! |
go get -u github.com/tiborvass/gomod GO111MODULE=on gomod init GO111MODULE=on go mod tidy GO111MODULE=on go mod vendor Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
|
Updated to upstream docker/cli |
The AuthConfig type was forked from the docker/docker API types in commit 27b2797 to reduce the dependency on the docker API types in BuildKit and Buildx (see [buildkit#800]). Now that the API is a separate module with minimal dependencies, this should no longer be a big concern, so this patch un-forks the type. [buildkit#800]: moby/buildkit#800 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
What I did:
Because of golang/go#25556 I created https://github.com/tiborvass/gomod to convert vendor.conf to go.mod. It's only needed for conversion. Regular
go modcan be used once go.mod/go.sum are created.Related docker/cli#1642 :Right now, the docker cli dependency is that of Tonis's fork which reduces the dependencies. I submitted a hopefully mergeable version upstream so that we no longer need to depend on a fork.
Until then, the reason we need to update the docker cli dependency is because
go mod tidyerrors out on logrus's Sirupsen/sirupsen mismatch, due to the docker cli fork not containing the import path update for logrus.The PR got merged, I removed the fork!
Since
go moduses$GOPATH/pkg/modto store its cache, I'm mounting it as type=cache in a newvendor.buildkit.Dockerfile. Legacy vendor.Dockerfile redownloads everything every time like vndr used to.
In order for
go buildto honor thevendor/folder when go modules are enabled, I had to add an-mod vendorargument.I verified that the validate-vendor script works, but please verify as well.
It would be good to try updating some dependencies as a way to test this.
TODO:
-mod vendor