diff --git a/README.md b/README.md index 3076df0e3898bce671e247c9be261f395026a79e..01f084532bcf01e0a5fcb29867c6834485ec2c5a 100644 --- a/README.md +++ b/README.md @@ -22,20 +22,32 @@ # after — one binary, one config, one command: cacher download "$key" "$out" --url "$url" ``` +Same collapse for docker images: + +```sh +cacher docker download "$key" "$image:tag" --pull +``` + +Releases and changelog: [bigbes.pages.srht.bigb.es/ci-cacher](https://bigbes.pages.srht.bigb.es/ci-cacher/). + ## Install ```sh -# Pre-built linux-amd64 binary (latest tag): +# Pre-built binary (latest tag). Substitute your platform: +# cacher-linux-amd64, cacher-linux-arm64, +# cacher-darwin-amd64, cacher-darwin-arm64 wget https://bigbes.pages.srht.bigb.es/ci-cacher/cacher-linux-amd64 -O ~/.local/bin/cacher chmod +x ~/.local/bin/cacher -# Pin to a specific build by sha256 (printed on the publish.yml job page): +# Pin to a known sha256 (checksums.txt lives next to the binaries): wget https://bigbes.pages.srht.bigb.es/ci-cacher/cacher-linux-amd64 -O ~/.local/bin/cacher echo " ~/.local/bin/cacher" | sha256sum -c # From source: go install go.bigb.es/cacher@latest ``` + +Verify with `cacher version`. ## Setup @@ -79,14 +91,27 @@ ```sh cacher upload my-key /path/to/artifact # skip if present cacher upload my-key /path/to/artifact --force # overwrite cacher exists my-key # exit 0 hit, 1 miss -cacher list my-prefix # debug +cacher list my-prefix # /-delimited (aws s3 ls) +cacher list my-prefix --recursive # flat +cacher list --root # ignore configured prefix cacher delete my-key # invalidate ``` ### Docker images — streamed save/load + +For an image pulled from a registry, the cache-or-pull pattern is a +single command: ```sh -# Build, cache, and reuse a docker image keyed by its Dockerfile content: +# Cache HIT → docker load from S3. MISS → docker pull + seed S3 + tag stays local. +cacher docker download "docker/dxflrs-garage-v2.3.0.tar.zst" \ + dxflrs/garage:v2.3.0 --pull +``` + +For images you build locally, drive the cache by hand — same primitives, +key by Dockerfile content: + +```sh KEY=$(cacher key "images/{hash}.tar.zst" --hash-from Dockerfile) if ! cacher docker exists "$KEY"; then @@ -145,6 +170,54 @@ `cacher key