summaryrefslogtreecommitdiffstats
path: root/recipes-demo
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-01-14 04:47:15 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-01-21 18:00:26 -0500
commitf83a83eb3979e3bc671190650731acf8a5b9ecd3 (patch)
tree66aebfd2079c21985942b8fee8c03ec17e48b7ff /recipes-demo
parent3b77c90d6dd76173fb198f6f32a091a68d098495 (diff)
downloadmeta-virtualization-f83a83eb3979e3bc671190650731acf8a5b9ecd3.tar.gz
recipes: add multi-layer OCI example recipes
Add example recipes demonstrating multi-layer OCI image building: alpine-oci-base_3.19.bb: - Fetches Alpine 3.19 from Docker Hub using container-bundle - Uses CONTAINER_BUNDLE_DEPLOY for use as OCI_BASE_IMAGE source - Pinned digest for reproducible builds app-container-alpine.bb: - Demonstrates external base image usage - Layers Yocto packages (busybox) on top of Alpine - Uses OCI_IMAGE_CMD for Docker-like behavior app-container-layered.bb: - Demonstrates local base image usage - Layers Yocto packages on top of container-base - Uses OCI_IMAGE_CMD for Docker-like behavior Both app containers produce 2-layer OCI images where the base layer is shared, reducing storage and transfer costs. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-demo')
-rw-r--r--recipes-demo/images/app-container-alpine.bb35
-rw-r--r--recipes-demo/images/app-container-layered.bb36
2 files changed, 71 insertions, 0 deletions
diff --git a/recipes-demo/images/app-container-alpine.bb b/recipes-demo/images/app-container-alpine.bb
new file mode 100644
index 00000000..a685f011
--- /dev/null
+++ b/recipes-demo/images/app-container-alpine.bb
@@ -0,0 +1,35 @@
1SUMMARY = "Container image based on Alpine OCI base"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
5# Use fetched Alpine as base layer
6OCI_BASE_IMAGE = "alpine-oci-base"
7
8# Use CMD (not ENTRYPOINT) so `docker run image /bin/sh` works as expected
9OCI_IMAGE_CMD = "/bin/sh -c 'echo Hello from Alpine-based Yocto container'"
10
11IMAGE_FSTYPES = "container oci"
12inherit image
13inherit image-oci
14
15IMAGE_FEATURES = ""
16IMAGE_LINGUAS = ""
17NO_RECOMMENDATIONS = "1"
18
19# Add Yocto-built packages on top of Alpine
20IMAGE_INSTALL = " \
21 base-files \
22 base-passwd \
23 netbase \
24 busybox \
25"
26
27# Allow build with or without a specific kernel
28IMAGE_CONTAINER_NO_DUMMY = "1"
29
30# Workaround /var/volatile for now
31ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; "
32rootfs_fixup_var_volatile () {
33 install -m 1777 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/tmp
34 install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/log
35}
diff --git a/recipes-demo/images/app-container-layered.bb b/recipes-demo/images/app-container-layered.bb
new file mode 100644
index 00000000..2762aae1
--- /dev/null
+++ b/recipes-demo/images/app-container-layered.bb
@@ -0,0 +1,36 @@
1SUMMARY = "Layered Application container - test OCI_BASE_IMAGE"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
5# Use container-base as the base layer
6OCI_BASE_IMAGE = "container-base"
7
8# Use CMD so `docker run image /bin/sh` works as expected
9OCI_IMAGE_CMD = "/bin/sh -c 'echo Hello from layered container'"
10
11IMAGE_FSTYPES = "container oci"
12inherit image
13inherit image-oci
14
15IMAGE_FEATURES = ""
16IMAGE_LINGUAS = ""
17NO_RECOMMENDATIONS = "1"
18
19# Only add packages not in base - this is the "app layer"
20IMAGE_INSTALL = " \
21 base-files \
22 base-passwd \
23 netbase \
24 busybox \
25 curl \
26"
27
28# Allow build with or without a specific kernel
29IMAGE_CONTAINER_NO_DUMMY = "1"
30
31# Workaround /var/volatile for now
32ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; "
33rootfs_fixup_var_volatile () {
34 install -m 1777 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/tmp
35 install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/log
36}