Skip to content

Commit 1978a6b

Browse files
authored
Merge pull request #22 from thediveo/develop
feat: buildkit support
2 parents 083dcaf + b3db11e commit 1978a6b

File tree

7 files changed

+163
-132
lines changed

7 files changed

+163
-132
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
![build and test](https://github.com/thediveo/morbyd/actions/workflows/buildandtest.yaml/badge.svg?branch=master)
88
![goroutines](https://img.shields.io/badge/go%20routines-not%20leaking-success)
99
[![Go Report Card](https://goreportcard.com/badge/github.com/thediveo/morbyd)](https://goreportcard.com/report/github.com/thediveo/morbyd)
10-
![Coverage](https://img.shields.io/badge/Coverage-98.2%25-brightgreen)
10+
![Coverage](https://img.shields.io/badge/Coverage-97.8%25-brightgreen)
1111

1212
`morbyd` is a thin layer on top of the standard Docker Go client to easily build
1313
and run throw-away test Docker images and containers. And to easily run commands

build/options.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ func WithAlwaysRemoveIntermediateContainers() Opt {
161161
}
162162
}
163163

164+
// WithBuildKit requests building with BuildKit.
165+
func WithBuildKit() Opt {
166+
return func(o *Options) error {
167+
o.Version = build.BuilderBuildKit
168+
return nil
169+
}
170+
}
171+
172+
// WithBuilderV1 requests building with the classic/deprecated builder in the
173+
// Docker demon. Please note that this is still morbyd's default unless
174+
// [WithBuildKit] is explicitly specified. Because we're ... morbyd.
175+
func WithBuilderV1() Opt {
176+
return func(o *Options) error {
177+
o.Version = build.BuilderV1
178+
return nil
179+
}
180+
}
181+
164182
// WithOutput set the writer to which the output of the image build process is
165183
// sent to.
166184
func WithOutput(w io.Writer) Opt {

build/options_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var _ = Describe("image build options", func() {
3131
WithTag("fool"),
3232
WithTag("fool:oncemore"),
3333

34+
WithBuildKit(),
35+
3436
WithBuildArg("foobar="),
3537
WithBuildArgs("foo=bar", "baz"),
3638

@@ -48,6 +50,7 @@ var _ = Describe("image build options", func() {
4850
Expect(opt(&bios)).NotTo(HaveOccurred())
4951
}
5052
Expect(bios.Tags).To(ConsistOf("fool", "fool:oncemore"))
53+
Expect(bios.Version).To(Equal(build.BuilderBuildKit))
5154
Expect(bios.BuildArgs).To(And(
5255
HaveLen(3),
5356
HaveKeyWithValue("foo", gs.PointTo(Equal("bar"))),
@@ -83,4 +86,10 @@ var _ = Describe("image build options", func() {
8386
Expect(WithLabels("foo=", "")(&opts)).Error().To(HaveOccurred())
8487
})
8588

89+
It("sets builder v1", func() {
90+
var opts Options
91+
Expect(WithBuilderV1()(&opts)).Error().NotTo(HaveOccurred())
92+
Expect(opts.Version).To(Equal(build.BuilderV1))
93+
})
94+
8695
})

go.mod

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
module github.com/thediveo/morbyd
22

3-
go 1.24.0
3+
go 1.24.3
44

55
require (
6+
github.com/containerd/errdefs v1.0.0
67
github.com/docker/docker v28.5.2+incompatible
78
github.com/docker/go-connections v0.6.0
89
github.com/docker/go-units v0.5.0
10+
github.com/golang/protobuf v1.5.4
11+
github.com/moby/buildkit v0.26.3
12+
github.com/moby/go-archive v0.1.0
913
github.com/moby/patternmatcher v0.6.0
1014
github.com/onsi/ginkgo/v2 v2.27.5
1115
github.com/onsi/gomega v1.39.0
@@ -19,31 +23,31 @@ require (
1923

2024
require (
2125
github.com/Masterminds/semver/v3 v3.4.0 // indirect
22-
github.com/containerd/errdefs v1.0.0 // indirect
2326
github.com/containerd/errdefs/pkg v0.3.0 // indirect
24-
github.com/moby/go-archive v0.1.0 // indirect
2527
github.com/moby/sys/atomicwriter v0.1.0 // indirect
26-
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
27-
go.uber.org/automaxprocs v1.6.0 // indirect
28+
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
29+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
2830
go.yaml.in/yaml/v3 v3.0.4 // indirect
2931
golang.org/x/mod v0.32.0 // indirect
3032
golang.org/x/sync v0.19.0 // indirect
33+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
34+
google.golang.org/grpc v1.76.0 // indirect
35+
google.golang.org/protobuf v1.36.10 // indirect
3136
)
3237

3338
require (
3439
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
3540
github.com/Microsoft/go-winio v0.6.2 // indirect
3641
github.com/containerd/log v0.1.0 // indirect
37-
github.com/containerd/platforms v0.2.1
42+
github.com/containerd/platforms v1.0.0-rc.2
3843
github.com/distribution/reference v0.6.0 // indirect
3944
github.com/felixge/httpsnoop v1.0.4 // indirect
4045
github.com/go-logr/logr v1.4.3 // indirect
4146
github.com/go-logr/stdr v1.2.2 // indirect
4247
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
43-
github.com/gogo/protobuf v1.3.2 // indirect
4448
github.com/google/go-cmp v0.7.0 // indirect
45-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
46-
github.com/klauspost/compress v1.18.0 // indirect
49+
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 // indirect
50+
github.com/klauspost/compress v1.18.1 // indirect
4751
github.com/moby/docker-image-spec v1.3.1 // indirect
4852
github.com/moby/sys/sequential v0.6.0 // indirect
4953
github.com/moby/sys/user v0.4.0 // indirect
@@ -52,18 +56,13 @@ require (
5256
github.com/morikuni/aec v1.0.0 // indirect
5357
github.com/opencontainers/go-digest v1.0.0 // indirect
5458
github.com/sirupsen/logrus v1.9.3 // indirect
55-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
56-
go.opentelemetry.io/otel v1.35.0 // indirect
57-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
58-
go.opentelemetry.io/otel/metric v1.35.0 // indirect
59-
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
60-
go.opentelemetry.io/otel/trace v1.35.0 // indirect
59+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
60+
go.opentelemetry.io/otel v1.38.0 // indirect
61+
go.opentelemetry.io/otel/metric v1.38.0 // indirect
62+
go.opentelemetry.io/otel/trace v1.38.0 // indirect
6163
golang.org/x/crypto v0.47.0
6264
golang.org/x/net v0.49.0 // indirect
6365
golang.org/x/sys v0.40.0 // indirect
6466
golang.org/x/text v0.33.0 // indirect
65-
golang.org/x/time v0.3.0 // indirect
6667
golang.org/x/tools v0.41.0 // indirect
67-
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
68-
gopkg.in/yaml.v3 v3.0.1 // indirect
6968
)

0 commit comments

Comments
 (0)