diff options
Diffstat (limited to 'classes/image-oci.bbclass')
-rw-r--r-- | classes/image-oci.bbclass | 84 |
1 files changed, 17 insertions, 67 deletions
diff --git a/classes/image-oci.bbclass b/classes/image-oci.bbclass index c256b12c..464ea3b4 100644 --- a/classes/image-oci.bbclass +++ b/classes/image-oci.bbclass | |||
@@ -16,19 +16,32 @@ | |||
16 | # And then create the bundle: | 16 | # And then create the bundle: |
17 | # % oci-image-tool create --ref name=latest container-base-<arch>-<stamp>.rootfs-oci container-base-oci-bundle | 17 | # % oci-image-tool create --ref name=latest container-base-<arch>-<stamp>.rootfs-oci container-base-oci-bundle |
18 | # | 18 | # |
19 | # Alternatively, the bundle can be created with umoci (use --rootless if sudo is not available) | ||
20 | # % sudo umoci unpack --image container-base-<arch>-<stamp>.rootfs-oci:latest container-base-oci-bundle | ||
21 | # | ||
19 | # Or to copy (push) the oci image to a docker registry, skopeo can be used (vary the | 22 | # Or to copy (push) the oci image to a docker registry, skopeo can be used (vary the |
20 | # tag based on the created oci image: | 23 | # tag based on the created oci image: |
21 | # | 24 | # |
22 | # % skopeo copy --dest-creds <username>:<password> oci:container-base-<arch>-<stamp>:latest docker://zeddii/container-base | 25 | # % skopeo copy --dest-creds <username>:<password> oci:container-base-<arch>-<stamp>:latest docker://zeddii/container-base |
23 | # | 26 | # |
27 | # If your build host architecture matches the target, you can execute the unbundled | ||
28 | # container with runc: | ||
29 | # | ||
30 | # % sudo runc run -b container-base-oci-bundle ctr-build | ||
31 | # / % uname -a | ||
32 | # Linux mrsdalloway 4.18.0-25-generic #26-Ubuntu SMP Mon Jun 24 09:32:08 UTC 2019 x86_64 GNU/Linux | ||
33 | # | ||
24 | 34 | ||
25 | # We'd probably get this through the container image typdep, but just | 35 | # We'd probably get this through the container image typdep, but just |
26 | # to be sure, we'll repeat it here. | 36 | # to be sure, we'll repeat it here. |
27 | ROOTFS_BOOTSTRAP_INSTALL = "" | 37 | ROOTFS_BOOTSTRAP_INSTALL = "" |
28 | # we want container and tar.bz2's to be created | 38 | # we want container and tar.bz2's to be created |
29 | IMAGE_TYPEDEP_oci = "container tar.bz2" | 39 | IMAGE_TYPEDEP_oci = "container tar.bz2" |
40 | |||
30 | # sloci is the script/project that will create the oci image | 41 | # sloci is the script/project that will create the oci image |
31 | do_image_oci[depends] += "sloci-image-native:do_populate_sysroot" | 42 | # OCI_IMAGE_BACKEND ?= "sloci-image" |
43 | OCI_IMAGE_BACKEND ?= "umoci" | ||
44 | do_image_oci[depends] += "${OCI_IMAGE_BACKEND}-native:do_populate_sysroot" | ||
32 | 45 | ||
33 | # | 46 | # |
34 | # image type configuration block | 47 | # image type configuration block |
@@ -75,70 +88,7 @@ def oci_map_subarch(a, f, d): | |||
75 | return '' | 88 | return '' |
76 | return '' | 89 | return '' |
77 | 90 | ||
78 | IMAGE_CMD_oci() { | 91 | # the IMAGE_CMD_oci comes from the .inc |
79 | sloci_options="" | 92 | OCI_IMAGE_BACKEND_INC ?= "${@"image-oci-" + "${OCI_IMAGE_BACKEND}" + ".inc"}" |
80 | 93 | include ${OCI_IMAGE_BACKEND_INC} | |
81 | bbdebug 1 "OCI image settings:" | ||
82 | bbdebug 1 " author: ${OCI_IMAGE_AUTHOR}" | ||
83 | bbdebug 1 " author email: ${OCI_IMAGE_AUTHOR_EMAIL}" | ||
84 | bbdebug 1 " tag: ${OCI_IMAGE_TAG}" | ||
85 | bbdebug 1 " arch: ${OCI_IMAGE_ARCH}" | ||
86 | bbdebug 1 " subarch: ${OCI_IMAGE_SUBARCH}" | ||
87 | bbdebug 1 " entrypoint: ${OCI_IMAGE_ENTRYPOINT}" | ||
88 | bbdebug 1 " entrypoing args: ${OCI_IMAGE_ENTRYPOINT_ARGS}" | ||
89 | bbdebug 1 " labels: ${OCI_IMAGE_LABELS}" | ||
90 | bbdebug 1 " uid: ${OCI_IMAGE_RUNTIME_UID}" | ||
91 | bbdebug 1 " working dir: ${OCI_IMAGE_WORKINGDIR}" | ||
92 | bbdebug 1 " env vars: ${OCI_IMAGE_ENV_VARS}" | ||
93 | bbdebug 1 " ports: ${OCI_IMAGE_PORTS}" | ||
94 | |||
95 | # Change into the image deploy dir to avoid having any output operations capture | ||
96 | # long directories or the location. | ||
97 | cd ${IMGDEPLOYDIR} | ||
98 | |||
99 | oci_image_label_options="" | ||
100 | if [ -n "${OCI_IMAGE_LABELS}" ]; then | ||
101 | for l in ${OCI_IMAGE_LABELS}; do | ||
102 | oci_image_label_options="${oci_image_label_options} --label ${l}" | ||
103 | done | ||
104 | fi | ||
105 | oci_image_env_options="" | ||
106 | if [ -n "${OCI_IMAGE_ENV_VARS}" ]; then | ||
107 | for l in ${OCI_IMAGE_ENV_VARS}; do | ||
108 | oci_image_env_options="${oci_image_env_options} --env ${l}" | ||
109 | done | ||
110 | fi | ||
111 | oci_image_port_options="" | ||
112 | if [ -n "${OCI_IMAGE_PORTS}" ]; then | ||
113 | for l in ${OCI_IMAGE_PORTS}; do | ||
114 | oci_image_port_options="${oci_image_port_options} --port ${l}" | ||
115 | done | ||
116 | fi | ||
117 | |||
118 | if [ -n "${OCI_IMAGE_RUNTIME_UID}" ]; then | ||
119 | oci_image_user_options="--user ${OCI_IMAGE_RUNTIME_UID}" | ||
120 | fi | ||
121 | |||
122 | if [ -n "${OCI_IMAGE_WORKINGDIR}" ]; then | ||
123 | oci_image_working_dir_options="--working-dir ${OCI_IMAGE_WORKINGDIR}" | ||
124 | fi | ||
125 | |||
126 | if [ -n "${OCI_IMAGE_TAR_OUTPUT}" ]; then | ||
127 | sloci_options="$sloci_options --tar" | ||
128 | fi | ||
129 | 94 | ||
130 | # options that always appear are required for a valid oci container image | ||
131 | # others are optional based on settings. | ||
132 | sloci-image $sloci_options \ | ||
133 | --arch ${OCI_IMAGE_ARCH} \ | ||
134 | --arch-variant "${OCI_IMAGE_SUBARCH}" \ | ||
135 | --entrypoint ${OCI_IMAGE_ENTRYPOINT} \ | ||
136 | --cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}" \ | ||
137 | --author ${OCI_IMAGE_AUTHOR_EMAIL} \ | ||
138 | ${oci_image_user_options} \ | ||
139 | ${oci_image_label_options} \ | ||
140 | ${oci_image_env_options} \ | ||
141 | ${oci_image_working_dir_options} \ | ||
142 | ${oci_image_port_options} \ | ||
143 | ${IMAGE_ROOTFS} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}-oci:${OCI_IMAGE_TAG} | ||
144 | } | ||