You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
dazzle is a rather experimental Docker/OCI image builder. Its goal is to build independent layers where a change to one layer does *not* invalidate the ones sitting "above" it.
8
8
9
-
**Beware** Recently the format for [dazzle builds was changed](https://github.com/gitpod-io/dazzle/commit/ceaa19ef6562e03108c8ea9474d2c627a452a7ca), moving from a single Dockerfile to one per "chunk"/layer. It is also about 5x faster, more reliable and less hacky.
9
+
**Beware** Recently the format for [dazzle builds was changed](https://github.com/gitpod-io/dazzle/commit/ceaa19ef6562e03108c8ea9474d2c627a452a7ca), moving from a single Dockerfile to one per "chunk"/layer. It is also about 5x faster, more reliable and less hacky.
10
10
11
11
## How does it work?
12
12
dazzle has three main capabilities.
@@ -15,36 +15,39 @@ dazzle has three main capabilities.
15
15
3._run tests against images_: to ensure that an image is capable of what we think it should be - especially after merging - dazzle supports simple tests and assertions that run against Docker images.
16
16
17
17
## Would I want to use this?
18
+
18
19
Not ordinarily, no. For example, if you're packing your service/app/software/unicorn you're probably better of with a regular Docker image build and well established means for optimizing that one (think multi-stage builds, proper layer ordering).
19
20
20
21
If however you are building images which consist of a lot of independent "concerns", i.e. chunks that can be strictly separated, then this might for you.
21
22
For example, if you're building an image that serves as a collection of tools, the layer hierarchy imposed by regular builds doesn't fit so well.
22
23
23
24
## Limitations and caveats
25
+
24
26
- build args are not supported at the moment
25
27
- there are virtually no tests covering this so things might just break
26
28
- consider this alpha-level software
27
29
28
30
### Requirements
29
-
Install and run [buildkit](https://github.com/moby/buildkit/releases) - currently 0.8.3 - in the background.
31
+
Install and run [buildkit](https://github.com/moby/buildkit/releases) - currently 0.10.0 - in the background.
30
32
Pull and run a docker registry.
31
33
32
-
NOTE: if you are running it in Gitpod this is done for you!
34
+
NOTE: if you are running it in Gitpod this is done for you!
33
35
34
36
```bash
35
-
sudo su -c "cd /usr; curl -L https://github.com/moby/buildkit/releases/download/v0.8.3/buildkit-v0.8.3.linux-amd64.tar.gz | tar xvz"
37
+
sudo su -c "cd /usr; curl -L https://github.com/moby/buildkit/releases/download/v0.10.0/buildkit-v0.10.0.linux-amd64.tar.gz | tar xvz"
36
38
docker run -p 5000:5000 --name registry --rm registry:2
Starts a new dazzle project. If you don't know where to start, this is the place.
84
88
85
89
## build
86
-
```
90
+
91
+
```shell
87
92
$ dazzle build --help
88
93
Builds a Docker image with independent layers
89
94
@@ -107,7 +112,8 @@ Dazzle can build regular Docker files much like `docker build` would. `build` wi
107
112
Dazzle cannot reproducibly build layers but can only re-use previously built ones. To ensure reusable layers and maximize Docker cache hits, dazzle itself caches the layers it builds in a Docker registry.
108
113
109
114
## combine
110
-
```
115
+
116
+
```shell
111
117
$ dazzle combine --help
112
118
Combines previously built chunks into a single image
113
119
@@ -132,6 +138,7 @@ Dazzle can combine previously built chunks into a single image. For example `daz
132
138
One can pre-register such chunk combinations using `dazzle project add-combination`.
133
139
134
140
The `dazzle.yaml` file specifies the list of available combinations. Those combinations can also reference each other:
141
+
135
142
```yaml
136
143
combiner:
137
144
combinations:
@@ -176,7 +183,7 @@ For example:
176
183
entrypoint: [bash, -i, -c]
177
184
command: [foo -version]
178
185
assert:
179
-
- stderr.indexOf("1.8.0_312") != -1
186
+
- stderr.indexOf("1.8.0_312") != -1
180
187
181
188
```
182
189
@@ -229,9 +236,11 @@ It accepts an array of string.
229
236
Each string is a key value pair separated by `=`.
230
237
231
238
## Testing approach
239
+
232
240
While the test runner is standalone, the linux+amd64 version is embedded into the dazzle binary using [go.rice](https://github.com/GeertJohan/go.rice) and go generate - see [build.sh](./pkg/test/runner/build.sh).
233
241
TODO: use go:embed?
234
242
Note that if you make changes to code in the test runner you will need to re-embed the runner into the binary in order to use it via dazzle.
243
+
235
244
```bash
236
245
go generate ./...
237
246
```
@@ -240,20 +249,23 @@ The test runner binary is extracted and copied to the generated image where it i
240
249
The exit code, stdout & stderr are captured and returned for evaluation against the assertions in the test specification.
241
250
242
251
While of limited practical use, it is *possible* to run the test runner standalone using a base64-encoded JSON blob as a parameter:
252
+
243
253
```bash
244
254
$ go run pkg/test/runner/main.go eyJEZXNjIjoiaXQgc2hvdWxkIGhhdmUgR28gaW4gdmVyc2lvbiAxLjEzIiwiU2tpcCI6ZmFsc2UsIlVzZXIiOiIiLCJDb21tYW5kIjpbImdvIiwidmVyc2lvbiJdLCJFbnRyeXBvaW50IjpudWxsLCJFbnYiOm51bGwsIkFzc2VydGlvbnMiOlsic3Rkb3V0LmluZGV4T2YoXCJnbzEuMTFcIikgIT0gLTEiXX0=
The stdout/err are returned as base64-encoded values.
249
259
They can be extracted using jq e.g.:
260
+
250
261
```bash
251
262
$ go run pkg/test/runner/main.go eyJEZXNjIjoiaXQgc2hvdWxkIGhhdmUgR28gaW4gdmVyc2lvbiAxLjEzIiwiU2tpcCI6ZmFsc2UsIlVzZXIiOiIiLCJDb21tYW5kIjpbImdvIiwidmVyc2lvbiJdLCJFbnRyeXBvaW50IjpudWxsLCJFbnYiOm51bGwsIkFzc2VydGlvbnMiOlsic3Rkb3V0LmluZGV4T2YoXCJnbzEuMTFcIikgIT0gLTEiXX0= | jq -r '.Stdout | @base64d'
252
263
go version go1.16.4 linux/amd64
253
264
```
254
265
255
266
## Integration tests
256
-
There is an integration test for the build command in pkg/dazzle/build_test.go - TestProjectChunk_test_integration and a shell script to run it.
267
+
268
+
There is an integration test for the build command in pkg/dazzle/build_test.go - TestProjectChunk_test_integration and a shell script to run it.
257
269
The integration test does an end-to-end check along with editing a test and re-running to ensure only the test image is updated.
258
270
259
271
It requires a running Buildkitd instance at unix:///run/buildkit/buildkitd.sock and a docker registry on 127.0.0.1:5000 (i.e. as this workspace is setup on startup).
@@ -262,4 +274,4 @@ Override the env vars BUILDKIT_ADDR and TARGET_REF as required prior to running
0 commit comments