Skip to content

Commit b55bf20

Browse files
authored
Merge pull request #221 from AkihiroSuda/buildtag
*: update build tags (`containerd` -> `no_oci_worker`)
2 parents 1281fcd + 2a33b2e commit b55bf20

File tree

16 files changed

+83
-83
lines changed

16 files changed

+83
-83
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BINARIES=bin/buildd bin/buildctl
2-
BINARIES_EXTRA=bin/buildd-standalone bin/buildd-containerd bin/buildctl-darwin bin/buildd.exe bin/buildctl.exe
2+
BINARIES_EXTRA=bin/buildd.oci_only bin/buildd.containerd_only bin/buildctl-darwin bin/buildd.exe bin/buildctl.exe
33
DESTDIR=/usr/local
44

55
binaries: $(BINARIES)

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The following command installs `buildd` and `buildctl` to `/usr/local/bin`:
4040
$ make && sudo make install
4141
```
4242

43-
You can also use `make binaries-all` to prepare `buildd-containerd` (containerd worker only) and `buildd-standalone` (OCI worker only).
43+
You can also use `make binaries-all` to prepare `buildd.containerd_only` and `buildd.oci_only`.
4444

4545
`examples/buildkit*` directory contains scripts that define how to build different configurations of BuildKit and its dependencies using the `client` package. Running one of these script generates a protobuf definition of a build graph. Note that the script itself does not execute any steps of the build.
4646

@@ -50,7 +50,7 @@ You can use `buildctl debug dump-llb` to see what data is in this definition. Ad
5050
go run examples/buildkit0/buildkit.go | buildctl debug dump-llb | jq .
5151
```
5252

53-
To start building use `buildctl build` command. The example script accepts `--target` flag to choose between `containerd` and `standalone` configurations. In standalone mode BuildKit binaries are built together with `runc`. In containerd mode, the `containerd` binary is built as well from the upstream repo.
53+
To start building use `buildctl build` command. The example script accepts `--target` flag to choose between `containerd-worker-only` and `oci-worker-only` configurations. In OCI worker mode BuildKit binaries are built together with `runc`. In containerd worker mode, the `containerd` binary is built as well from the upstream repo.
5454

5555
```bash
5656
go run examples/buildkit0/buildkit.go | buildctl build
@@ -143,13 +143,12 @@ buildkit can be also used by running the `buildd` daemon inside a Docker contain
143143
To run daemon in a container:
144144
145145
```
146-
docker run -d --privileged -p 1234:1234 tonistiigi/buildkit:standalone --addr tcp://0.0.0.0:1234
146+
docker run -d --privileged -p 1234:1234 tonistiigi/buildkit --addr tcp://0.0.0.0:1234 --oci-worker=true --containerd-worker=false
147147
export BUILDKIT_HOST=tcp://0.0.0.0:1234
148148
buildctl build --help
149149
```
150150
151-
The `tonistiigi/buildkit:standalone` image can be built locally using the Dockerfile in `./hack/dockerfiles/test.Dockerfile`.
152-
151+
The `tonistiigi/buildkit` image can be built locally using the Dockerfile in `./hack/dockerfiles/test.Dockerfile`.
153152
154153
#### Supported runc version
155154
@@ -174,7 +173,7 @@ make test TESTPKGS=./client
174173
make test TESTPKGS=./client TESTFLAGS="--run /TestCallDiskUsage -v"
175174
176175
# run all integration tests with a specific worker
177-
# supported workers are standalone and containerd
176+
# supported workers are oci and containerd
178177
make test TESTPKGS=./client TESTFLAGS="--run //worker=containerd -v"
179178
```
180179

cmd/buildd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func newWorkerController(c *cli.Context, wiOpt workerInitializerOpt) (*worker.Co
250250
}
251251
nWorkers := len(wc.GetAll())
252252
if nWorkers == 0 {
253-
return nil, errors.New("no worker found, build the buildkit daemon with tags? (e.g. \"standalone\", \"containerd\")")
253+
return nil, errors.New("no worker found, rebuild the buildkit daemon?")
254254
}
255255
defaultWorker, err := wc.GetDefault()
256256
if err != nil {

cmd/buildd/main_containerd.go renamed to cmd/buildd/main_containerd_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build containerd
1+
// +build linux,!no_containerd_worker
22

33
package main
44

cmd/buildd/main_standalone.go renamed to cmd/buildd/main_oci_worker.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// +build standalone
2-
3-
// TODO(AkihiroSuda): s/standalone/oci/g
1+
// +build linux,!no_oci_worker
42

53
package main
64

examples/buildkit0/buildkit.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
)
1010

1111
type buildOpt struct {
12-
target string
13-
containerd string
14-
runc string
12+
withContainerd bool
13+
containerd string
14+
runc string
1515
}
1616

1717
func main() {
1818
var opt buildOpt
19-
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
19+
flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
2020
flag.StringVar(&opt.containerd, "containerd", "v1.0.0", "containerd version")
2121
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
2222
flag.Parse()
@@ -62,23 +62,23 @@ func buildkit(opt buildOpt) llb.State {
6262
Run(llb.Shlex("git clone https://github.com/moby/buildkit.git /go/src/github.com/moby/buildkit")).
6363
Dir("/go/src/github.com/moby/buildkit")
6464

65-
builddStandalone := src.
66-
Run(llb.Shlex("go build -o /bin/buildd-standalone -tags standalone ./cmd/buildd"))
65+
builddOCIWorkerOnly := src.
66+
Run(llb.Shlex("go build -o /bin/buildd.oci_only -tags no_containerd_worker ./cmd/buildd"))
6767

68-
builddContainerd := src.
69-
Run(llb.Shlex("go build -o /bin/buildd-containerd -tags containerd ./cmd/buildd"))
68+
buildd := src.
69+
Run(llb.Shlex("go build -o /bin/buildd ./cmd/buildd"))
7070

7171
buildctl := src.
7272
Run(llb.Shlex("go build -o /bin/buildctl ./cmd/buildctl"))
7373

7474
r := llb.Image("docker.io/library/alpine:latest")
7575
r = copy(buildctl.Root(), "/bin/buildctl", r, "/bin/")
7676
r = copy(runc(opt.runc), "/usr/bin/runc", r, "/bin/")
77-
if opt.target == "containerd" {
77+
if opt.withContainerd {
7878
r = copy(containerd(opt.containerd), "/go/src/github.com/containerd/containerd/bin/containerd", r, "/bin/")
79-
r = copy(builddContainerd.Root(), "/bin/buildd-containerd", r, "/bin/")
79+
r = copy(buildd.Root(), "/bin/buildd", r, "/bin/")
8080
} else {
81-
r = copy(builddStandalone.Root(), "/bin/buildd-standalone", r, "/bin/")
81+
r = copy(builddOCIWorkerOnly.Root(), "/bin/buildd.oci_only", r, "/bin/")
8282
}
8383
return r
8484
}

examples/buildkit1/buildkit.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
)
1010

1111
type buildOpt struct {
12-
target string
13-
containerd string
14-
runc string
12+
withContainerd bool
13+
containerd string
14+
runc string
1515
}
1616

1717
func main() {
1818
var opt buildOpt
19-
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
19+
flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
2020
flag.StringVar(&opt.containerd, "containerd", "v1.0.0", "containerd version")
2121
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
2222
flag.Parse()
@@ -57,11 +57,11 @@ func containerd(version string) llb.State {
5757
func buildkit(opt buildOpt) llb.State {
5858
src := goBuildBase().With(goFromGit("github.com/moby/buildkit", "master"))
5959

60-
builddStandalone := src.
61-
Run(llb.Shlex("go build -o /bin/buildd-standalone -tags standalone ./cmd/buildd")).Root()
60+
builddOCIWorkerOnly := src.
61+
Run(llb.Shlex("go build -o /bin/buildd.oci_only -tags no_containerd_worker ./cmd/buildd")).Root()
6262

63-
builddContainerd := src.
64-
Run(llb.Shlex("go build -o /bin/buildd-containerd -tags containerd ./cmd/buildd")).Root()
63+
buildd := src.
64+
Run(llb.Shlex("go build -o /bin/buildd ./cmd/buildd")).Root()
6565

6666
buildctl := src.
6767
Run(llb.Shlex("go build -o /bin/buildctl ./cmd/buildctl")).Root()
@@ -71,12 +71,12 @@ func buildkit(opt buildOpt) llb.State {
7171
copyFrom(runc(opt.runc), "/usr/bin/runc", "/bin/"),
7272
)
7373

74-
if opt.target == "containerd" {
74+
if opt.withContainerd {
7575
return r.With(
7676
copyFrom(containerd(opt.containerd), "/go/src/github.com/containerd/containerd/bin/containerd", "/bin/"),
77-
copyFrom(builddContainerd, "/bin/buildd-containerd", "/bin/"))
77+
copyFrom(buildd, "/bin/buildd", "/bin/"))
7878
}
79-
return r.With(copyFrom(builddStandalone, "/bin/buildd-standalone", "/bin/"))
79+
return r.With(copyFrom(builddOCIWorkerOnly, "/bin/buildd.oci_only", "/bin/"))
8080
}
8181

8282
// goFromGit is a helper for cloning a git repo, checking out a tag and copying

examples/buildkit2/buildkit.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
)
1010

1111
type buildOpt struct {
12-
target string
13-
containerd string
14-
runc string
12+
withContainerd bool
13+
containerd string
14+
runc string
1515
}
1616

1717
func main() {
1818
var opt buildOpt
19-
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
19+
flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
2020
flag.StringVar(&opt.containerd, "containerd", "v1.0.0", "containerd version")
2121
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
2222
flag.Parse()
@@ -66,9 +66,9 @@ func containerd(version string) llb.State {
6666
func buildkit(opt buildOpt) llb.State {
6767
run := goRepo(goBuildBase(), "github.com/moby/buildkit", "master")
6868

69-
builddStandalone := run(llb.Shlex("go build -o ./bin/buildd-standalone -tags standalone ./cmd/buildd"))
69+
builddOCIWorkerOnly := run(llb.Shlex("go build -o ./bin/buildd.oci_only -tags no_containerd_worker ./cmd/buildd"))
7070

71-
builddContainerd := run(llb.Shlex("go build -o ./bin/buildd-containerd -tags containerd ./cmd/buildd"))
71+
buildd := run(llb.Shlex("go build -o ./bin/buildd ./cmd/buildd"))
7272

7373
buildctl := run(llb.Shlex("go build -o ./bin/buildctl ./cmd/buildctl"))
7474

@@ -77,12 +77,12 @@ func buildkit(opt buildOpt) llb.State {
7777
copyAll(runc(opt.runc), "/bin"),
7878
)
7979

80-
if opt.target == "containerd" {
80+
if opt.withContainerd {
8181
return r.With(
8282
copyAll(containerd(opt.containerd), "/bin"),
83-
copyAll(builddContainerd, "/bin"))
83+
copyAll(buildd, "/bin"))
8484
}
85-
return r.With(copyAll(builddStandalone, "/bin"))
85+
return r.With(copyAll(builddOCIWorkerOnly, "/bin"))
8686
}
8787

8888
func copyAll(src llb.State, destPath string) llb.StateOption {

examples/buildkit3/buildkit.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99
)
1010

1111
type buildOpt struct {
12-
target string
13-
containerd string
14-
runc string
15-
buildkit string
12+
withContainerd bool
13+
containerd string
14+
runc string
15+
buildkit string
1616
}
1717

1818
func main() {
1919
var opt buildOpt
20-
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
20+
flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
2121
flag.StringVar(&opt.containerd, "containerd", "v1.0.0", "containerd version")
2222
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
2323
flag.StringVar(&opt.buildkit, "buildkit", "master", "buildkit version")
@@ -82,9 +82,9 @@ func buildkit(opt buildOpt) llb.State {
8282
}
8383
run := goRepo(goBuildBase(), repo, src)
8484

85-
builddStandalone := run(llb.Shlex("go build -o /out/buildd-standalone -tags standalone ./cmd/buildd"))
85+
builddOCIWorkerOnly := run(llb.Shlex("go build -o /out/buildd.oci_only -tags no_containerd_worker ./cmd/buildd"))
8686

87-
builddContainerd := run(llb.Shlex("go build -o /out/buildd-containerd -tags containerd ./cmd/buildd"))
87+
buildd := run(llb.Shlex("go build -o /out/buildd ./cmd/buildd"))
8888

8989
buildctl := run(llb.Shlex("go build -o /out/buildctl ./cmd/buildctl"))
9090

@@ -93,12 +93,12 @@ func buildkit(opt buildOpt) llb.State {
9393
copyAll(runc(opt.runc), "/"),
9494
)
9595

96-
if opt.target == "containerd" {
96+
if opt.withContainerd {
9797
return r.With(
9898
copyAll(containerd(opt.containerd), "/"),
99-
copyAll(builddContainerd, "/"))
99+
copyAll(buildd, "/"))
100100
}
101-
return r.With(copyAll(builddStandalone, "/"))
101+
return r.With(copyAll(builddOCIWorkerOnly, "/"))
102102
}
103103

104104
func copyAll(src llb.State, destPath string) llb.StateOption {

examples/gobuild/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func run() error {
3535
Source: src,
3636
MountPath: "/go/src/github.com/moby/buildkit",
3737
Pkg: "github.com/moby/buildkit/cmd/buildd",
38-
BuildTags: []string{"standalone"},
38+
BuildTags: []string{"no_containerd_worker"},
3939
})
4040
if err != nil {
4141
return err

frontend/dockerfile/dockerfile_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ RUN ["ls"]
609609
cmd := sb.Cmd(args + " --exporter=image --exporter-opt=name=" + target)
610610
require.NoError(t, cmd.Run())
611611

612-
// TODO: expose this test to standalone
612+
// TODO: expose this test to OCI worker
613613

614614
var cdAddress string
615615
if cd, ok := sb.(interface {

hack/dockerfiles/test.Dockerfile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG RUNC_VERSION=74a17296470088de3805e138d3d87c62e613dfc4
22
ARG CONTAINERD_VERSION=v1.0.0
3-
# available targets: buildd (standalone+containerd), buildd-standalone, buildd-containerd
3+
# available targets: buildd, buildd.oci_only, buildd.containerd_only
44
ARG BUILDKIT_TARGET=buildd
55
ARG REGISTRY_VERSION=2.6
66

@@ -22,7 +22,7 @@ RUN go build -ldflags '-d' -o /usr/bin/buildctl ./cmd/buildctl
2222

2323
FROM buildkit-base AS buildd
2424
ENV CGO_ENABLED=0
25-
RUN go build -ldflags '-d' -o /usr/bin/buildd -tags "standalone containerd" ./cmd/buildd
25+
RUN go build -ldflags '-d' -o /usr/bin/buildd ./cmd/buildd
2626

2727
# test dependencies begin here
2828
FROM gobuild-base AS runc
@@ -47,20 +47,19 @@ COPY --from=runc /usr/bin/runc /usr/bin/runc
4747
COPY --from=containerd /go/src/github.com/containerd/containerd/bin/containerd* /usr/bin/
4848

4949

50-
FROM buildkit-base AS buildd-standalone
50+
FROM buildkit-base AS buildd.oci_only
5151
ENV CGO_ENABLED=0
52-
RUN go build -ldflags '-d' -o /usr/bin/buildd-standalone -tags standalone ./cmd/buildd
52+
RUN go build -ldflags '-d' -o /usr/bin/buildd.oci_only -tags no_containerd_worker ./cmd/buildd
5353

54-
FROM buildkit-base AS buildd-containerd
54+
FROM buildkit-base AS buildd.containerd_only
5555
ENV CGO_ENABLED=0
56-
RUN go build -ldflags '-d' -o /usr/bin/buildd-containerd -tags containerd ./cmd/buildd
56+
RUN go build -ldflags '-d' -o /usr/bin/buildd.containerd_only -tags no_oci_worker ./cmd/buildd
5757

5858
FROM registry:$REGISTRY_VERSION AS registry
5959

6060
FROM unit-tests AS integration-tests
6161
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
62-
COPY --from=buildd-containerd /usr/bin/buildd-containerd /usr/bin
63-
COPY --from=buildd-standalone /usr/bin/buildd-standalone /usr/bin
62+
COPY --from=buildd /usr/bin/buildd /usr/bin
6463
COPY --from=registry /bin/registry /usr/bin
6564

6665
FROM gobuild-base AS cross-windows
@@ -78,24 +77,25 @@ FROM alpine AS buildkit-export
7877
RUN apk add --no-cache git
7978
VOLUME /var/lib/buildkit
8079

81-
# Copy together all binaries for standalone+containerd mode
80+
# Copy together all binaries for oci+containerd mode
8281
FROM buildkit-export AS buildkit-buildd
8382
COPY --from=runc /usr/bin/runc /usr/bin/
8483
COPY --from=buildd /usr/bin/buildd /usr/bin/
8584
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
85+
ENTRYPOINT ["buildd"]
8686

87-
# Copy together all binaries needed for standalone mode
88-
FROM buildkit-export AS buildkit-buildd-standalone
89-
COPY --from=buildd-standalone /usr/bin/buildd-standalone /usr/bin/
87+
# Copy together all binaries needed for oci worker mode
88+
FROM buildkit-export AS buildkit-buildd.oci_only
89+
COPY --from=buildd.oci_only /usr/bin/buildd.oci_only /usr/bin/
9090
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
91-
ENTRYPOINT ["buildd-standalone"]
91+
ENTRYPOINT ["buildd.oci_only"]
9292

93-
# Copy together all binaries for containerd mode
94-
FROM buildkit-export AS buildkit-buildd-containerd
93+
# Copy together all binaries for containerd worker mode
94+
FROM buildkit-export AS buildkit-buildd.containerd_only
9595
COPY --from=runc /usr/bin/runc /usr/bin/
96-
COPY --from=buildd-containerd /usr/bin/buildd-containerd /usr/bin/
96+
COPY --from=buildd.containerd_only /usr/bin/buildd.containerd_only /usr/bin/
9797
COPY --from=buildctl /usr/bin/buildctl /usr/bin/
98-
ENTRYPOINT ["buildd-containerd"]
98+
ENTRYPOINT ["buildd.containerd_only"]
9999

100100
FROM alpine AS containerd-runtime
101101
COPY --from=runc /usr/bin/runc /usr/bin/

hack/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eu -o pipefail -x
55
# update this to iidfile after 17.06
66
docker build -t buildkit:test --target integration-tests -f ./hack/dockerfiles/test.Dockerfile --force-rm .
77

8-
docker run --rm -v /tmp --privileged buildkit:test go test -tags standalone ${TESTFLAGS:--v} ${TESTPKGS:-./...}
8+
docker run --rm -v /tmp --privileged buildkit:test go test -tags no_containerd_worker ${TESTFLAGS:--v} ${TESTPKGS:-./...}
99

1010
docker run --rm buildkit:test go build ./frontend/gateway/client
1111
docker run --rm buildkit:test go build ./frontend/dockerfile/cmd/dockerfile-frontend

util/testutil/integration/containerd.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (c *containerd) New() (sb Sandbox, cl func() error, err error) {
2424
if err := lookupBinary("containerd"); err != nil {
2525
return nil, nil, err
2626
}
27-
if err := lookupBinary("buildd-containerd"); err != nil {
27+
if err := lookupBinary("buildd"); err != nil {
2828
return nil, nil, err
2929
}
3030
if err := requireRoot(); err != nil {
@@ -64,7 +64,10 @@ func (c *containerd) New() (sb Sandbox, cl func() error, err error) {
6464
return nil, nil, err
6565
}
6666

67-
builddSock, stop, err := runBuildd([]string{"buildd-containerd", "--containerd-worker-addr", address}, logs)
67+
builddSock, stop, err := runBuildd([]string{"buildd",
68+
"--oci-worker=false",
69+
"--containerd-worker=true",
70+
"--containerd-worker-addr", address}, logs)
6871
if err != nil {
6972
return nil, nil, err
7073
}

0 commit comments

Comments
 (0)