summaryrefslogtreecommitdiffstats
path: root/classes/image-oci.bbclass
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-01-12 20:15:39 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-02-09 03:32:52 +0000
commit8b19fa53399cdeb18b1cdd41276ecac5a4f659b0 (patch)
treeb7abf17923d1f1aa129f4264446fdd5e481efb70 /classes/image-oci.bbclass
parent1d8968199aa812d5c9bdc8089e0eb53da25cd877 (diff)
downloadmeta-virtualization-8b19fa53399cdeb18b1cdd41276ecac5a4f659b0.tar.gz
image-oci: add build-time metadata labels for traceability
Automatically embed source and build information into OCI images using standard OCI annotations (opencontainers.org image-spec): - org.opencontainers.image.revision: git commit SHA - org.opencontainers.image.ref.name: git branch name - org.opencontainers.image.created: ISO 8601 build timestamp - org.opencontainers.image.version: PV (if meaningful) New variables: - OCI_IMAGE_REVISION: explicit SHA override (auto-detects from TOPDIR) - OCI_IMAGE_BRANCH: explicit branch override (auto-detects from TOPDIR) - OCI_IMAGE_BUILD_DATE: explicit timestamp override (auto-generated) - OCI_IMAGE_APP_RECIPE: hook for future cross-recipe extraction Set any variable to "none" to disable that specific label. This enables 1:1 traceability between container images and source code, following industry best practices for CI/CD and release management. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'classes/image-oci.bbclass')
-rw-r--r--classes/image-oci.bbclass44
1 files changed, 43 insertions, 1 deletions
diff --git a/classes/image-oci.bbclass b/classes/image-oci.bbclass
index 0ec5c487..70f32bf1 100644
--- a/classes/image-oci.bbclass
+++ b/classes/image-oci.bbclass
@@ -65,11 +65,53 @@ OCI_IMAGE_STOPSIGNAL ?= ""
65# format: <port>/tcp, <port>/udp, or <port> (same as <port>/tcp). 65# format: <port>/tcp, <port>/udp, or <port> (same as <port>/tcp).
66OCI_IMAGE_PORTS ?= "" 66OCI_IMAGE_PORTS ?= ""
67 67
68# key=value list of labels 68# key=value list of labels (user-defined)
69OCI_IMAGE_LABELS ?= "" 69OCI_IMAGE_LABELS ?= ""
70# key=value list of environment variables 70# key=value list of environment variables
71OCI_IMAGE_ENV_VARS ?= "" 71OCI_IMAGE_ENV_VARS ?= ""
72 72
73# =============================================================================
74# Build-time metadata for traceability
75# =============================================================================
76#
77# These variables embed source info into OCI image labels for traceability.
78# Standard OCI annotations are used: https://github.com/opencontainers/image-spec/blob/main/annotations.md
79#
80# OCI_IMAGE_APP_RECIPE: Recipe name for the "main application" in the container.
81# If set, future versions may auto-extract SRCREV/branch from this recipe.
82# For now, it's documentation and a hook point.
83#
84# OCI_IMAGE_REVISION: Git commit SHA (short or full).
85# - If set: uses this value
86# - If empty: auto-detects from TOPDIR git repo
87# - Set to "none" to disable
88#
89# OCI_IMAGE_BRANCH: Git branch name.
90# - If set: uses this value
91# - If empty: auto-detects from TOPDIR git repo
92# - Set to "none" to disable
93#
94# OCI_IMAGE_BUILD_DATE: ISO 8601 timestamp.
95# - Auto-generated at build time
96#
97# These become standard OCI labels:
98# org.opencontainers.image.revision = OCI_IMAGE_REVISION
99# org.opencontainers.image.ref.name = OCI_IMAGE_BRANCH
100# org.opencontainers.image.created = OCI_IMAGE_BUILD_DATE
101# org.opencontainers.image.version = PV (if meaningful)
102
103# Application recipe for traceability (documentation/future use)
104OCI_IMAGE_APP_RECIPE ?= ""
105
106# Explicit overrides - if set, these are used instead of auto-detection
107# Set to "none" to disable a specific label
108OCI_IMAGE_REVISION ?= ""
109OCI_IMAGE_BRANCH ?= ""
110OCI_IMAGE_BUILD_DATE ?= ""
111
112# Enable/disable auto-detection of git metadata (set to "0" to disable)
113OCI_IMAGE_AUTO_LABELS ?= "1"
114
73# whether the oci image dir should be left as a directory, or 115# whether the oci image dir should be left as a directory, or
74# bundled into a tarball. 116# bundled into a tarball.
75OCI_IMAGE_TAR_OUTPUT ?= "true" 117OCI_IMAGE_TAR_OUTPUT ?= "true"