diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-05-07 12:16:41 -0400 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-07-19 13:36:17 -0400 |
| commit | 96c47ad0b8c95e6f6401d2a479c3444bb7b6415e (patch) | |
| tree | 67c29e9f2fba9a3bd85c1c252a9b8c6fb9238608 /classes/image-oci-sloci-image.inc | |
| parent | 62137a394fdaa46abbbd539cd6e83d2607520bf0 (diff) | |
| download | meta-virtualization-96c47ad0b8c95e6f6401d2a479c3444bb7b6415e.tar.gz | |
oci-images: create backend .inc files
As part of allowing different types of oci images to be created,
we split our IMG_cmd into .inc files that can then be specific to
the selected type.
For the umoci backend: We can take the same options as sloci
expects and use umoci to create images.
The resulting OCI image is similar, but by using umoci, we set
the stage to do multi-tag, or multi-layer images in the future.
But for now, we are functionally equivalent to the sloci backend.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'classes/image-oci-sloci-image.inc')
| -rw-r--r-- | classes/image-oci-sloci-image.inc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/classes/image-oci-sloci-image.inc b/classes/image-oci-sloci-image.inc new file mode 100644 index 00000000..36d3c2da --- /dev/null +++ b/classes/image-oci-sloci-image.inc | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | IMAGE_CMD_oci() { | ||
| 2 | sloci_options="" | ||
| 3 | |||
| 4 | bbdebug 1 "OCI image settings:" | ||
| 5 | bbdebug 1 " author: ${OCI_IMAGE_AUTHOR}" | ||
| 6 | bbdebug 1 " author email: ${OCI_IMAGE_AUTHOR_EMAIL}" | ||
| 7 | bbdebug 1 " tag: ${OCI_IMAGE_TAG}" | ||
| 8 | bbdebug 1 " arch: ${OCI_IMAGE_ARCH}" | ||
| 9 | bbdebug 1 " subarch: ${OCI_IMAGE_SUBARCH}" | ||
| 10 | bbdebug 1 " entrypoint: ${OCI_IMAGE_ENTRYPOINT}" | ||
| 11 | bbdebug 1 " entrypoing args: ${OCI_IMAGE_ENTRYPOINT_ARGS}" | ||
| 12 | bbdebug 1 " labels: ${OCI_IMAGE_LABELS}" | ||
| 13 | bbdebug 1 " uid: ${OCI_IMAGE_RUNTIME_UID}" | ||
| 14 | bbdebug 1 " working dir: ${OCI_IMAGE_WORKINGDIR}" | ||
| 15 | bbdebug 1 " env vars: ${OCI_IMAGE_ENV_VARS}" | ||
| 16 | bbdebug 1 " ports: ${OCI_IMAGE_PORTS}" | ||
| 17 | |||
| 18 | # Change into the image deploy dir to avoid having any output operations capture | ||
| 19 | # long directories or the location. | ||
| 20 | cd ${IMGDEPLOYDIR} | ||
| 21 | |||
| 22 | oci_image_label_options="" | ||
| 23 | if [ -n "${OCI_IMAGE_LABELS}" ]; then | ||
| 24 | for l in ${OCI_IMAGE_LABELS}; do | ||
| 25 | oci_image_label_options="${oci_image_label_options} --label ${l}" | ||
| 26 | done | ||
| 27 | fi | ||
| 28 | oci_image_env_options="" | ||
| 29 | if [ -n "${OCI_IMAGE_ENV_VARS}" ]; then | ||
| 30 | for l in ${OCI_IMAGE_ENV_VARS}; do | ||
| 31 | oci_image_env_options="${oci_image_env_options} --env ${l}" | ||
| 32 | done | ||
| 33 | fi | ||
| 34 | oci_image_port_options="" | ||
| 35 | if [ -n "${OCI_IMAGE_PORTS}" ]; then | ||
| 36 | for l in ${OCI_IMAGE_PORTS}; do | ||
| 37 | oci_image_port_options="${oci_image_port_options} --port ${l}" | ||
| 38 | done | ||
| 39 | fi | ||
| 40 | |||
| 41 | if [ -n "${OCI_IMAGE_RUNTIME_UID}" ]; then | ||
| 42 | oci_image_user_options="--user ${OCI_IMAGE_RUNTIME_UID}" | ||
| 43 | fi | ||
| 44 | |||
| 45 | if [ -n "${OCI_IMAGE_WORKINGDIR}" ]; then | ||
| 46 | oci_image_working_dir_options="--working-dir ${OCI_IMAGE_WORKINGDIR}" | ||
| 47 | fi | ||
| 48 | |||
| 49 | if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then | ||
| 50 | sloci_options="$sloci_options --tar" | ||
| 51 | fi | ||
| 52 | |||
| 53 | # options that always appear are required for a valid oci container image | ||
| 54 | # others are optional based on settings. | ||
| 55 | sloci-image $sloci_options \ | ||
| 56 | --arch ${OCI_IMAGE_ARCH} \ | ||
| 57 | --arch-variant "${OCI_IMAGE_SUBARCH}" \ | ||
| 58 | --entrypoint ${OCI_IMAGE_ENTRYPOINT} \ | ||
| 59 | --cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" \ | ||
| 60 | --author ${OCI_IMAGE_AUTHOR_EMAIL} \ | ||
| 61 | ${oci_image_user_options} \ | ||
| 62 | ${oci_image_label_options} \ | ||
| 63 | ${oci_image_env_options} \ | ||
| 64 | ${oci_image_working_dir_options} \ | ||
| 65 | ${oci_image_port_options} \ | ||
| 66 | ${IMAGE_ROOTFS} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci:${OCI_IMAGE_TAG} | ||
| 67 | } | ||
