diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-01-14 20:58:34 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-02-09 03:32:52 +0000 |
| commit | 4fd9190b7f2f7260b90c7de1609944c96fcf6f64 (patch) | |
| tree | 1f7268a586df34642a9b0562a9abaa3c1b97f35c /recipes-demo/images | |
| parent | 4ddc9e489307a31b25600b9073edb09110740fb8 (diff) | |
| download | meta-virtualization-4fd9190b7f2f7260b90c7de1609944c96fcf6f64.tar.gz | |
image-oci: add multi-layer OCI image support with OCI_LAYERS
Add support for creating multi-layer OCI images with explicit layer
definitions via OCI_LAYERS variable. This enables fine-grained control
over container layer composition.
New variables:
- OCI_LAYER_MODE: Set to "multi" for explicit layer definitions
- OCI_LAYERS: Define layers as "name:type:content" entries
- packages: Install specific packages in a layer
- directories: Copy directories from IMAGE_ROOTFS
- files: Copy specific files from IMAGE_ROOTFS
Package installation uses Yocto's package manager classes (RpmPM,
OpkgPM) for consistency with do_rootfs, rather than calling dnf/opkg
directly.
Example usage:
OCI_LAYER_MODE = "multi"
OCI_LAYERS = "\
base:packages:base-files+base-passwd+netbase \
shell:packages:busybox \
app:packages:curl \
"
This creates a 3-layer OCI image with discrete base, shell, and app
layers that can be shared and cached independently.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-demo/images')
| -rw-r--r-- | recipes-demo/images/app-container-multilayer.bb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/recipes-demo/images/app-container-multilayer.bb b/recipes-demo/images/app-container-multilayer.bb new file mode 100644 index 00000000..6a3f2042 --- /dev/null +++ b/recipes-demo/images/app-container-multilayer.bb | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | SUMMARY = "Multi-layer Application container - test OCI_LAYERS" | ||
| 2 | DESCRIPTION = "Demonstrates OCI_LAYER_MODE = 'multi' with explicit layer definitions" | ||
| 3 | LICENSE = "MIT" | ||
| 4 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
| 5 | |||
| 6 | # Multi-layer mode: create explicit layers instead of single rootfs layer | ||
| 7 | OCI_LAYER_MODE = "multi" | ||
| 8 | |||
| 9 | # Define layers: each layer contains specific packages | ||
| 10 | # Format: "name:type:content" where content uses + as delimiter for multiple items | ||
| 11 | OCI_LAYERS = "\ | ||
| 12 | base:packages:base-files+base-passwd+netbase \ | ||
| 13 | shell:packages:busybox \ | ||
| 14 | app:packages:curl \ | ||
| 15 | " | ||
| 16 | |||
| 17 | # Use CMD so `docker run image /bin/sh` works as expected | ||
| 18 | OCI_IMAGE_CMD = "/bin/sh -c 'echo Hello from multi-layer container && curl --version'" | ||
| 19 | |||
| 20 | IMAGE_FSTYPES = "container oci" | ||
| 21 | inherit image | ||
| 22 | inherit image-oci | ||
| 23 | |||
| 24 | IMAGE_FEATURES = "" | ||
| 25 | IMAGE_LINGUAS = "" | ||
| 26 | NO_RECOMMENDATIONS = "1" | ||
| 27 | |||
| 28 | # IMAGE_INSTALL triggers package builds via do_rootfs recrdeptask. | ||
| 29 | # Even for multi-layer mode, list packages here to ensure they're built. | ||
| 30 | # The PM will install them directly to layers from DEPLOY_DIR_IPK. | ||
| 31 | # Note: IMAGE_ROOTFS is still created but ignored for packages layers. | ||
| 32 | IMAGE_INSTALL = "base-files base-passwd netbase busybox curl" | ||
| 33 | |||
| 34 | # Allow build with or without a specific kernel | ||
| 35 | IMAGE_CONTAINER_NO_DUMMY = "1" | ||
| 36 | |||
| 37 | # Note: No ROOTFS_POSTPROCESS_COMMAND needed - IMAGE_ROOTFS is empty | ||
| 38 | # and PM handles installation directly to OCI layers | ||
