ocibuild_cache (ocibuild v0.10.4)
View SourceLayer caching for OCI image builds.
Caches downloaded base image layers locally to avoid re-downloading on every build.
Designed for CI/CD workflows where caching the _build/ocibuild_cache directory
provides significant build time improvements.
Cache location resolution (in order):
OCIBUILD_CACHE_DIRenvironment variable (explicit override)- Project root detection →
<project>/_build/ocibuild_cache/ - Fall back to
./_build/ocibuild_cache/(current directory)
Project root is detected by walking up the directory tree looking for
rebar.config, mix.exs, or gleam.toml.
CI Integration Example:
# GitHub Actions
- uses: actions/cache@v4
with:
path: _build/ocibuild_cache
key: ocibuild-${{ runner.os }}-${{ hashFiles('rebar.lock') }}
# GitLab CI
cache:
paths:
- _build/ocibuild_cache/
Summary
Functions
Get the cache directory path.
Clear the entire cache.
Get a cached blob by digest.
Store a blob in the cache.
Functions
-spec cache_dir() -> file:filename().
Get the cache directory path.
Resolution order:
OCIBUILD_CACHE_DIRenvironment variable- Project root +
_build/ocibuild_cache/ ./_build/ocibuild_cache/(current directory fallback)
-spec clear() -> ok | {error, term()}.
Clear the entire cache.
Removes all cached blobs. Use with caution as this will force re-download of all layers on the next build.
-spec get(binary()) -> {ok, binary()} | {error, not_found | corrupted | {invalid_digest, binary()}}.
Get a cached blob by digest.
Returns {ok, Data} if the blob is found and its digest matches.
Returns {error, not_found} if the blob is not in the cache.
Returns {error, corrupted} if the cached blob doesn't match its digest.
Returns {error, {invalid_digest, Digest}} if the digest format is invalid.
Store a blob in the cache.
The blob is stored under its digest, so it can be retrieved later with get/1.
The digest is computed from the data, not provided as a parameter, to ensure
that only valid data is cached.
Returns {error, {invalid_digest, Digest}} if the digest format is invalid.