feat(coreos-container-image): systemd can be installed in the image
Allow to use systemd as an IMAGE_FEATURES inside a container image
This commit is contained in:
parent
e9247d5cd0
commit
75c190ab38
|
|
@ -2,6 +2,12 @@ SUMMARY = "A lighttpd container image"
|
|||
|
||||
inherit coreos-container-image
|
||||
|
||||
# Install systemd in the container
|
||||
IMAGE_FEATURES += "systemd"
|
||||
|
||||
# Allow to log using systemd without password
|
||||
IMAGE_FEATURES += "empty-root-password"
|
||||
|
||||
IMAGE_INSTALL:append = " \
|
||||
busybox \
|
||||
lighttpd \
|
||||
|
|
|
|||
|
|
@ -3,5 +3,4 @@ SUMMARY = "A lighttpd container package"
|
|||
inherit coreos-container-package
|
||||
|
||||
CONTAINER_IMAGE = "coreos-container-image-lighttpd"
|
||||
PODMAN_RUN_OPTIONS = "-p 80:80 --entrypoint /usr/sbin/lighttpd"
|
||||
PODMAN_RUN_CMD = "-D -f /etc/lighttpd/lighttpd.conf"
|
||||
PODMAN_RUN_OPTIONS = "-p 80:80"
|
||||
|
|
|
|||
|
|
@ -22,12 +22,24 @@ COREOS_CONTAINER_IMAGE_BASE_INSTALL = '\
|
|||
COREOS_CONTAINER_IMAGE_EXTRA_INSTALL ?= ""
|
||||
IMAGE_INSTALL ?= "${COREOS_CONTAINER_IMAGE_BASE_INSTALL} ${COREOS_CONTAINER_IMAGE_EXTRA_INSTALL}"
|
||||
|
||||
# Images features for containers
|
||||
# OCI Parameters
|
||||
# ==============================================================================
|
||||
|
||||
OCI_IMAGE_ENTRYPOINT ?= "${@bb.utils.contains('IMAGE_FEATURES', 'systemd', '/usr/sbin/init', '/usr/bin/sh', d)}"
|
||||
|
||||
inherit image
|
||||
inherit image-oci
|
||||
|
||||
# Images features for containers
|
||||
# ==============================================================================
|
||||
|
||||
# Install systemd inside the container
|
||||
FEATURE_PACKAGES_systemd = "systemd"
|
||||
|
||||
|
||||
# Image Post processings
|
||||
# ==============================================================================
|
||||
|
||||
IMAGE_CMD:oci:append() {
|
||||
# meta-virtualization default IMAGE_CMD doesn't create a symlink on kirkstone
|
||||
image_link_name="${IMAGE_LINK_NAME}${IMAGE_NAME_SUFFIX}-oci"
|
||||
|
|
@ -41,17 +53,27 @@ IMAGE_CMD:oci:append() {
|
|||
|
||||
# Workaround /var/volatile for now
|
||||
# See layers/meta-virtualization/recipes-extended/images/container-base.bb
|
||||
ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('IMAGE_FEATURES', 'init-manager', '', 'rootfs_fixup_var_volatile ; ', d)}"
|
||||
ROOTFS_POSTPROCESS_COMMAND += "rootfs_fixup_var_volatile ; "
|
||||
rootfs_fixup_var_volatile () {
|
||||
install -m 1777 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/tmp
|
||||
install -m 755 -d ${IMAGE_ROOTFS}/${localstatedir}/volatile/log
|
||||
|
||||
# When using systemd, systemd is responsible to link /var/{log,tmp} to /var/volutile/{log,tmp}
|
||||
# As container doesn't normally use systemd, we create the link by ourself here
|
||||
# in rootfs-postcommands.bbclass, when using initscripts theses link
|
||||
# are created by running ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
|
||||
# When the distro is configured to systemd, this is not done, so we need to
|
||||
# do it here manually (As systemd is not always included in the container)
|
||||
ln -sf ${localstatedir}/volatile/tmp ${IMAGE_ROOTFS}/${localstatedir}/tmp
|
||||
ln -sf ${localstatedir}/volatile/log ${IMAGE_ROOTFS}/${localstatedir}/log
|
||||
}
|
||||
|
||||
ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('IMAGE_FEATURES', 'systemd', 'rootfs_fixup_systemd ; ', '', d)}"
|
||||
rootfs_fixup_systemd () {
|
||||
# Mask systemd services that are not needed/doesn't work in a container
|
||||
# This ensure that the container doesn't boot in systemd emergency mode
|
||||
systemctl --root=${IMAGE_ROOTFS} mask systemd-remount-fs.service
|
||||
systemctl --root=${IMAGE_ROOTFS} mask var-volatile.mount
|
||||
}
|
||||
|
||||
# Add support for plugin classes like in coreos-image.bbclass
|
||||
COREOS_IMAGE_EXTRACLASSES ?= ""
|
||||
inherit ${COREOS_IMAGE_EXTRACLASSES}
|
||||
|
|
|
|||
Loading…
Reference in New Issue