summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/container-bundling.md64
1 files changed, 64 insertions, 0 deletions
diff --git a/docs/container-bundling.md b/docs/container-bundling.md
index a695a5b8..745622b5 100644
--- a/docs/container-bundling.md
+++ b/docs/container-bundling.md
@@ -193,6 +193,70 @@ OCI_LAYERS = "\
193" 193"
194``` 194```
195 195
196### Layer Caching
197
198Multi-layer builds cache pre-installed package layers for faster rebuilds.
199Installing packages requires configuring the package manager, resolving
200dependencies, and running post-install scripts - this is slow. Caching
201saves the fully-installed layer rootfs after the first build so subsequent
202builds can skip package installation entirely.
203
204#### Configuration
205
206 # Enabled by default
207 OCI_LAYER_CACHE ?= "1"
208 OCI_LAYER_CACHE_DIR ?= "${TOPDIR}/oci-layer-cache/${MACHINE}"
209
210#### Cache Key Components
211
212The cache key is a SHA256 hash of:
213
214| Component | Why It Matters |
215|-----------|----------------|
216| Layer name | Different layers cached separately |
217| Layer type | `packages` vs `directories` vs `files` |
218| Package list (sorted) | Adding/removing packages invalidates cache |
219| Package versions | Upgrading a package invalidates cache |
220| MACHINE, TUNE_PKGARCH | Architecture-specific packages |
221
222#### Advantages
223
224**Faster rebuilds**: Subsequent builds restore cached layers in ~1 second
225instead of ~10-30 seconds per layer for package installation.
226
227**Efficient development**: When only your app layer changes, base and
228dependency layers are restored from cache:
229
230 OCI_LAYERS = "\
231 base:packages:base-files+busybox \ # Cached - stable
232 deps:packages:python3+python3-pip \ # Cached - stable
233 app:packages:myapp \ # Rebuilt - changes often
234 "
235
236**Automatic invalidation**: Cache invalidates when packages change version,
237layers are modified, or architecture changes. No manual clearing needed.
238
239**Shared across recipes**: Cache stored in `${TOPDIR}/oci-layer-cache/` so
240recipes with identical layers share the same cached content.
241
242#### Build Log Example
243
244 # First build - cache misses
245 NOTE: OCI Cache MISS: Layer 'base' (base:base-files=3.0.14 ...)
246 NOTE: OCI Cache: Saving layer 'base' to cache (be88c180f651416b)
247 NOTE: OCI: Pre-installed packages for 3 layers (cache: 0 hits, 3 misses)
248
249 # Second build - cache hits
250 NOTE: OCI Cache HIT: Layer 'base' (be88c180f651416b)
251 NOTE: OCI: Pre-installed packages for 3 layers (cache: 3 hits, 0 misses)
252
253#### When to Disable
254
255Disable caching with `OCI_LAYER_CACHE = "0"` if you:
256- Suspect cache corruption
257- Need fully reproducible builds with no local state
258- Are debugging package installation issues
259
196### OCI_IMAGE_CMD vs OCI_IMAGE_ENTRYPOINT 260### OCI_IMAGE_CMD vs OCI_IMAGE_ENTRYPOINT
197 261
198 # CMD (default) - replaced when user passes arguments 262 # CMD (default) - replaced when user passes arguments