Skip to content

Commit 13016cd

Browse files
committed
Update docs
1 parent 056b90e commit 13016cd

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

.gitpod.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM gitpod/workspace-full
22
ENV TRIGGER_REBUILD=1
33
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sudo BINDIR=/usr/local/bin sh
4-
RUN sudo su -c "cd /usr; curl -L https://github.com/moby/buildkit/releases/download/v0.9.3/buildkit-v0.9.3.linux-amd64.tar.gz | tar xvz"
4+
RUN 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"
55
# NOTE: remove when workspace-full includes golangci
66
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo BINDIR=/usr/local/bin sh

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
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.
88

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.
1010

1111
## How does it work?
1212
dazzle has three main capabilities.
@@ -15,36 +15,39 @@ dazzle has three main capabilities.
1515
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.
1616

1717
## Would I want to use this?
18+
1819
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).
1920

2021
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.
2122
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.
2223

2324
## Limitations and caveats
25+
2426
- build args are not supported at the moment
2527
- there are virtually no tests covering this so things might just break
2628
- consider this alpha-level software
2729

2830
### 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.
3032
Pull and run a docker registry.
3133

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!
3335

3436
```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"
3638
docker run -p 5000:5000 --name registry --rm registry:2
3739
```
3840

3941
## Getting started
42+
4043
```bash
4144
# start a new project
4245
dazzle project init
4346

4447
# add our first chunk
4548
dazzle project init helloworld
4649
echo hello world > chunks/helloworld/hello.txt
47-
echo "COPY hello.txt /" >> chunks/helloworld/Dockerfile
50+
echo "COPY hello.txt /" >> chunks/helloworld/Dockerfile
4851

4952
# add another chunk, just for fun
5053
dazzle project init anotherchunk
@@ -64,7 +67,8 @@ dazzle combine eu.gcr.io/some-project/dazzle-test --all
6467
# Usage
6568

6669
## init
67-
```
70+
71+
```shell
6872
$ dazzle project init
6973
Starts a new dazzle project
7074

@@ -83,7 +87,8 @@ Global Flags:
8387
Starts a new dazzle project. If you don't know where to start, this is the place.
8488

8589
## build
86-
```
90+
91+
```shell
8792
$ dazzle build --help
8893
Builds a Docker image with independent layers
8994

@@ -107,7 +112,8 @@ Dazzle can build regular Docker files much like `docker build` would. `build` wi
107112
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.
108113

109114
## combine
110-
```
115+
116+
```shell
111117
$ dazzle combine --help
112118
Combines previously built chunks into a single image
113119

@@ -132,6 +138,7 @@ Dazzle can combine previously built chunks into a single image. For example `daz
132138
One can pre-register such chunk combinations using `dazzle project add-combination`.
133139

134140
The `dazzle.yaml` file specifies the list of available combinations. Those combinations can also reference each other:
141+
135142
```yaml
136143
combiner:
137144
combinations:
@@ -176,7 +183,7 @@ For example:
176183
entrypoint: [bash, -i, -c]
177184
command: [foo -version]
178185
assert:
179-
- stderr.indexOf("1.8.0_312") != -1
186+
- stderr.indexOf("1.8.0_312") != -1
180187
181188
```
182189

@@ -229,9 +236,11 @@ It accepts an array of string.
229236
Each string is a key value pair separated by `=`.
230237

231238
## Testing approach
239+
232240
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).
233241
TODO: use go:embed?
234242
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+
235244
```bash
236245
go generate ./...
237246
```
@@ -240,20 +249,23 @@ The test runner binary is extracted and copied to the generated image where it i
240249
The exit code, stdout & stderr are captured and returned for evaluation against the assertions in the test specification.
241250

242251
While of limited practical use, it is *possible* to run the test runner standalone using a base64-encoded JSON blob as a parameter:
252+
243253
```bash
244254
$ go run pkg/test/runner/main.go eyJEZXNjIjoiaXQgc2hvdWxkIGhhdmUgR28gaW4gdmVyc2lvbiAxLjEzIiwiU2tpcCI6ZmFsc2UsIlVzZXIiOiIiLCJDb21tYW5kIjpbImdvIiwidmVyc2lvbiJdLCJFbnRyeXBvaW50IjpudWxsLCJFbnYiOm51bGwsIkFzc2VydGlvbnMiOlsic3Rkb3V0LmluZGV4T2YoXCJnbzEuMTFcIikgIT0gLTEiXX0=
245255
{"Stdout":"Z28gdmVyc2lvbiBnbzEuMTYuNCBsaW51eC9hbWQ2NAo=","Stderr":"","StatusCode":0}
246256
```
247257

248258
The stdout/err are returned as base64-encoded values.
249259
They can be extracted using jq e.g.:
260+
250261
```bash
251262
$ go run pkg/test/runner/main.go eyJEZXNjIjoiaXQgc2hvdWxkIGhhdmUgR28gaW4gdmVyc2lvbiAxLjEzIiwiU2tpcCI6ZmFsc2UsIlVzZXIiOiIiLCJDb21tYW5kIjpbImdvIiwidmVyc2lvbiJdLCJFbnRyeXBvaW50IjpudWxsLCJFbnYiOm51bGwsIkFzc2VydGlvbnMiOlsic3Rkb3V0LmluZGV4T2YoXCJnbzEuMTFcIikgIT0gLTEiXX0= | jq -r '.Stdout | @base64d'
252263
go version go1.16.4 linux/amd64
253264
```
254265

255266
## 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.
257269
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.
258270

259271
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
262274

263275
```bash
264276
$ ./integration_tests.sh
265-
```
277+
```

0 commit comments

Comments
 (0)