Skip to content

Commit 6759360

Browse files
committed
add make rules and docs for integ test esgz image
add rules to Makefile for converting image to esgz and pushing it to a GHCR repository. add documentation with examples for converting an image to esgz. Signed-off-by: Gavin Inglis <[email protected]>
1 parent 2086286 commit 6759360

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,17 @@ $(STARGZ_BIN): $(STARGZ_DIR)/go.mod tools/stargz-builder-stamp
411411
--workdir /src/$(STARGZ_DIR) \
412412
localhost/$(STARGZ_BUILDER_NAME):$(DOCKER_IMAGE_TAG) \
413413
make
414+
415+
##########################
416+
# eStargz formatted image
417+
##########################
418+
CTR_REMOTE_BIN=$(STARGZ_DIR)/out/ctr-remote
419+
DEFAULT_BASE_IMAGE=public.ecr.aws/amazonlinux/amazonlinux:latest
420+
DEFAULT_ESGZ_IMAGE=ghcr.io/firecracker-microvm/firecracker-containerd/amazonlinux:latest-esgz
421+
.PHONY: esgz-test-image push-esgz-test-image
422+
esgz-test-image: stargz-snapshotter
423+
$(CTR_REMOTE_BIN) image pull $(DEFAULT_BASE_IMAGE)
424+
$(CTR_REMOTE_BIN) image optimize --oci $(DEFAULT_BASE_IMAGE) $(DEFAULT_ESGZ_IMAGE)
425+
426+
push-esgz-test-image:
427+
$(CTR_REMOTE_BIN) image push -u $(GH_USER):$(GH_PERSONAL_ACCESS_TOKEN) $(DEFAULT_ESGZ_IMAGE) $(DEFAULT_ESGZ_IMAGE)

snapshotter/demux/README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# snapshotter
2+
3+
## Building an esgz Formatted Image
4+
5+
The demux snapshotter uses a publicly available [eStargz](https://github.com/containerd/stargz-snapshotter/blob/main/docs/estargz.md) formatted image in its integration testing pipeline.
6+
This image has the reference `ghcr.io/firecracker-microvm/firecracker-containerd/amazonlinux:latest-esgz`.
7+
8+
### Optimize an Amazon Linux Container Image for esgz
9+
10+
The `ctr-remote` binary is needed to optimize an image for the esgz image format. Building the stargz-snapshotter submodule provides `ctr-remote`, a `ctr` wrapper, in `_submodules/stargz-snapshotter/out/ctr-remote`.
11+
Refer to the [containerd stargz-snapshotter documentation on `ctr-remote`](https://github.com/containerd/stargz-snapshotter/blob/main/docs/ctr-remote.md) for additional details.
12+
13+
The root level Makefile provides `make esgz-test-image` for pulling the latest Amazon Linux image locally and optimizing it for eStargz using `ctr-remote` into an image `ghcr.io/firecracker-microvm/firecracker-containerd/amazonlinux:latest-esgz`.
14+
Code owners of `firecracker-containerd` then push the eStargz optimized image as this publicly available reference using `make push-esgz-test-image` with proper credential environment variables `GH_USER` and `GH_PERSONAL_ACCESS_TOKEN` set.
15+
16+
### Example optimization and push to GHCR
17+
18+
Using default base and esgz images:
19+
20+
```bash
21+
$ make esgz-test-image
22+
$ GH_USER=xxx
23+
# set GH_PERSONAL_ACCESS_TOKEN with command substitution such that it does not show in shell history
24+
$ make \
25+
GH_USER=$GH_USER \
26+
GH_PERSONAL_ACCESS_TOKEN=`cat`
27+
push-esgz-test-image
28+
# enter personal access token and CTRL^D
29+
```
30+
31+
To pull, convert, and push to a repo where the user has permissions with custom base and esgz images:
32+
33+
```bash
34+
$ DEFAULT_BASE_IMAGE=public.ecr.aws/amazonlinux/amazonlinux:2022
35+
$ DEFAULT_ESGZ_IMAGE=ghcr.io/$DESTINATION_REPO/amazonlinux:2022-esgz
36+
$ make \
37+
DEFAULT_BASE_IMAGE=$DEFAULT_BASE_IMAGE \
38+
DEFAULT_ESGZ_IMAGE=$DEFAULT_ESGZ_IMAGE \
39+
esgz-test-image
40+
$ GH_USER=xxx
41+
# set GH_PERSONAL_ACCESS_TOKEN with command substitution such that it does not show in shell history
42+
$ make \
43+
GH_USER=$GH_USER \
44+
GH_PERSONAL_ACCESS_TOKEN=`cat`
45+
DEFAULT_ESGZ_IMAGE=$DEFAULT_ESGZ_IMAGE \
46+
push-esgz-test-image
47+
# enter personal access token and CTRL^D
48+
```
49+

0 commit comments

Comments
 (0)