diff options
| author | sakib.sajal@windriver.com <sakib.sajal@windriver.com> | 2022-05-25 19:43:47 -0400 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2022-06-20 12:11:17 -0400 |
| commit | 13839c7b135f94803534d67271b953a1b152699e (patch) | |
| tree | 87407183424e4dc2604525e7d365805a93200d70 | |
| parent | e4e136c520ffdddd94ec7d5a8515dffc3877cbf0 (diff) | |
| download | meta-virtualization-13839c7b135f94803534d67271b953a1b152699e.tar.gz | |
buildah: add recipe for buildah v1.26
buildah is a command line tool, to be installed and run on target,
that can be used to:
- create a working container, either from scratch or using an image
as a starting point
- create an image, either from a working container or via the
instructions in a Dockerfile
- images can be built in either the OCI image format or the
traditional upstream docker image format
- mount a working container's root filesystem for manipulation
- unmount a working container's root filesystem
- use the updated contents of a container's root filesystem as a
filesystem layer to create a new image
- delete a working container or an image
- rename a local container
Testing:
Setup the build directory:
$ . oe-init-build-env <build_dir>
Add to local.conf:
IMAGE_INSTALL:append = " buildah kernel-modules"
KERNEL_FEATURES += "features/overlayfs/overlayfs.cfgi \
features/netfilter/netfilter.scc \
features/lxc/lxc-enable.scc"
IMAGE_ROOTFS_EXTRA_SPACE = "5242880"
Build image:
$ bitbake core-image-minimal
Run the image:
$ runqemu nographic kvm qemuparams="-m 4096"
On target:
Pull an image:
> cnt=$(buildah from fedora)
Or build from Dockerfile
> buildah bud -t <image_name>:<tag> .
Mount the image:
> mnt=$(buildah mount ${cnt})
Install packages on the container rootfs:
> dnf install --installroot $mnt <packages_to_install> -y
Copy local files to the container:
> buildah copy $cnt <local_file> <dest_on_container>
Save the changes to an image
> buildah commit --format docker $cnt <name>:<tag>
Run the image using buildah:
> buildah run $cnt /bin/sh
Or using docker:
> docker run -it <name>:<tag>
Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
| -rw-r--r-- | recipes-containers/buildah/buildah_git.bb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/recipes-containers/buildah/buildah_git.bb b/recipes-containers/buildah/buildah_git.bb new file mode 100644 index 00000000..024e82c1 --- /dev/null +++ b/recipes-containers/buildah/buildah_git.bb | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | HOMEPAGE = "https://buildah.io" | ||
| 2 | SUMMARY = "A tool that facilitates building OCI container images." | ||
| 3 | DESCRIPTION = "A tool that facilitates building OCI container images." | ||
| 4 | |||
| 5 | # Apache-2.0 for containerd | ||
| 6 | LICENSE = "Apache-2.0" | ||
| 7 | LIC_FILES_CHKSUM = "file://src/github.com/containers/buildah/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" | ||
| 8 | |||
| 9 | S = "${WORKDIR}/git" | ||
| 10 | |||
| 11 | BUILDAH_VERSION = "1.26" | ||
| 12 | SRCREV_buildah = "0a9d6e6eaef2e2e7936313d449a4e226022eb865" | ||
| 13 | |||
| 14 | PV = "${BUILDAH_VERSION}" | ||
| 15 | |||
| 16 | inherit go | ||
| 17 | inherit goarch | ||
| 18 | inherit pkgconfig | ||
| 19 | |||
| 20 | GO_IMPORT = "github.com/containers/buildah" | ||
| 21 | GO_INSTALL = "${GO_IMPORT}" | ||
| 22 | GO_WORKDIR = "${GO_INSTALL}" | ||
| 23 | GOBUILDFLAGS += "-mod vendor" | ||
| 24 | |||
| 25 | SRC_URI = " \ | ||
| 26 | git://github.com/containers/buildah;branch=release-${BUILDAH_VERSION};name=buildah;protocol=https \ | ||
| 27 | " | ||
| 28 | |||
| 29 | DEPENDS = "libdevmapper btrfs-tools gpgme" | ||
| 30 | RDEPENDS:${PN} = "cgroup-lite fuse-overlayfs libdevmapper podman" | ||
| 31 | RDEPENDS:${PN}-dev = "bash perl" | ||
| 32 | |||
| 33 | do_compile:prepend() { | ||
| 34 | cd ${S}/src/github.com/containers/buildah | ||
| 35 | } | ||
| 36 | |||
| 37 | go_do_compile() { | ||
| 38 | export TMPDIR="${GOTMPDIR}" | ||
| 39 | if [ -n "${GO_INSTALL}" ]; then | ||
| 40 | if [ -n "${GO_LINKSHARED}" ]; then | ||
| 41 | ${GO} install ${GOBUILDFLAGS} ./cmd/buildah | ||
| 42 | ${GO} install ${GOBUILDFLAGS} ./tests/imgtype/imgtype.go | ||
| 43 | ${GO} install ${GOBUILDFLAGS} ./tests/copy/copy.go | ||
| 44 | rm -rf ${B}/bin | ||
| 45 | fi | ||
| 46 | ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./cmd/buildah | ||
| 47 | ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./tests/imgtype/imgtype.go | ||
| 48 | ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./tests/copy/copy.go | ||
| 49 | fi | ||
| 50 | } | ||
| 51 | |||
| 52 | do_install:append() { | ||
| 53 | dest_dir=${D}/${sysconfdir}/containers | ||
| 54 | mkdir -p ${dest_dir} | ||
| 55 | install -m 666 ${S}/src/github.com/containers/buildah/docs/samples/registries.conf ${dest_dir}/buildah.registries.conf.sample | ||
| 56 | install -m 666 ${S}/src/github.com/containers/buildah/tests/policy.json ${dest_dir}/buildah.policy.json.sample | ||
| 57 | } | ||
