diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/container-bundling.md | 64 |
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 | |||
| 198 | Multi-layer builds cache pre-installed package layers for faster rebuilds. | ||
| 199 | Installing packages requires configuring the package manager, resolving | ||
| 200 | dependencies, and running post-install scripts - this is slow. Caching | ||
| 201 | saves the fully-installed layer rootfs after the first build so subsequent | ||
| 202 | builds 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 | |||
| 212 | The 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 | ||
| 225 | instead of ~10-30 seconds per layer for package installation. | ||
| 226 | |||
| 227 | **Efficient development**: When only your app layer changes, base and | ||
| 228 | dependency 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, | ||
| 237 | layers are modified, or architecture changes. No manual clearing needed. | ||
| 238 | |||
| 239 | **Shared across recipes**: Cache stored in `${TOPDIR}/oci-layer-cache/` so | ||
| 240 | recipes 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 | |||
| 255 | Disable 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 |
