Skip to content

Instantly share code, notes, and snippets.

@akutz
Last active September 3, 2018 19:14
Show Gist options
  • Save akutz/393ac87d5f8d833a417bab0e75da0d4c to your computer and use it in GitHub Desktop.
Save akutz/393ac87d5f8d833a417bab0e75da0d4c to your computer and use it in GitHub Desktop.
Building cri-o

Building cri-o

This document demonstrates how to build cri-o from source using Docker.

$ docker run --rm akutz/crio:1.11.2.build | { base64 -D || base64 -d; } | tar tzv
-rwxr-xr-x  0 root   root 38462200 Sep  3 13:41 usr/local/bin/crio
-rwxr-xr-x  0 root   root    51120 Sep  3 13:41 usr/local/libexec/crio/conmon
-rwxr-xr-x  0 root   root   895392 Sep  3 13:41 usr/local/libexec/crio/pause
-rw-r--r--  0 root   root     5960 Sep  3 13:41 usr/local/share/man/man5/crio.conf.5
-rw-r--r--  0 root   root     8334 Sep  3 13:41 usr/local/share/man/man8/crio.8
-rw-r--r--  0 root   root     9239 Sep  3 14:06 etc/crio/crio.conf
-rw-r--r--  0 root   root    11658 Sep  3 14:06 etc/crio/seccomp.json
-rw-r--r--  0 root   root      332 Sep  3 14:06 usr/local/share/oci-umount/oci-umount.d/crio-umount.conf
-rw-r--r--  0 root   root       49 Sep  3 14:06 etc/crictl.yaml

Why cri-o?

For those interested in Why cri-o?, please see this well-written history of of container runtimes (CRI).

Build the docker image

The first step is to download the Dockerfile attached to this gist or execute the following:

$ curl -sSL https://gist.githubusercontent.com/akutz/393ac87d5f8d833a417bab0e75da0d4c/raw/b1c4a921df6487a281ebe1cd4b8c203c5250fd74/Dockerfile.crio-1.11.2.build | \
  docker build -t crio:1.11.2.build -f - .

Congrats, cri-o has been built.

Getting the cri-o assets

Now that cri-o image has been built, it's time to extract the assets. The simplest way to do this is to run the container and pipe its output into base64 -D (or base64 -d on Linux) and redirect the result into a file named crio-1.11.2.tar.gz.

$ docker run --rm crio:1.11.2.build | { base64 -D || base64 -d; } >crio-1.11.2.tar.gz

Listing the cri-o assets

Use the tar command to list the contents of the compressed archive:

$ tar tzvf crio-1.11.2.tar.gz
-rwxr-xr-x  0 root   root 38462200 Sep  3 13:41 usr/local/bin/crio
-rwxr-xr-x  0 root   root    51120 Sep  3 13:41 usr/local/libexec/crio/conmon
-rwxr-xr-x  0 root   root   895392 Sep  3 13:41 usr/local/libexec/crio/pause
-rw-r--r--  0 root   root     5960 Sep  3 13:41 usr/local/share/man/man5/crio.conf.5
-rw-r--r--  0 root   root     8334 Sep  3 13:41 usr/local/share/man/man8/crio.8
-rw-r--r--  0 root   root     9239 Sep  3 14:06 etc/crio/crio.conf
-rw-r--r--  0 root   root    11658 Sep  3 14:06 etc/crio/seccomp.json
-rw-r--r--  0 root   root      332 Sep  3 14:06 usr/local/share/oci-umount/oci-umount.d/crio-umount.conf
-rw-r--r--  0 root   root       49 Sep  3 14:06 etc/crictl.yaml
FROM akutz/golang:centos7.5.1804 as build
LABEL "maintainer" "Andrew Kutz <[email protected]>"
# Update the image.
RUN yum update -y
# Install the development toolchain.
RUN yum group install -y "Development Tools"
# Install the dependencies needed to build cri-o.
RUN yum install -y btrfs-progs-devel \
device-mapper-devel \
git \
glib2-devel \
glibc-devel \
glibc-static \
gpgme-devel \
libassuan-devel \
libgpg-error-devel \
libseccomp-devel \
libselinux-devel \
ostree-devel \
pkgconfig \
runc \
skopeo-containers
# Export the GOPATH
ENV GOPATH=/root/go
# The version of crio-o to build.
ENV CRIO_VERSION=v1.11.2
# Clone cri-o.
RUN git clone https://github.com/kubernetes-incubator/cri-o \
"${GOPATH}/kubernetes-incubator/cri-o"
# Jump into its source directory.
WORKDIR "${GOPATH}/kubernetes-incubator/cri-o"
# Checkout the version to build.
RUN git checkout -b "${CRIO_VERSION}" "${CRIO_VERSION}"
# Build cri-o.
RUN make install.tools
RUN make BUILDTAGS=""
RUN make install
RUN make install.config
# Create a tarball from the assets.
RUN tar czvf /root/crio.tar.gz \
/usr/local/bin/crio \
/usr/local/libexec/crio/conmon \
/usr/local/libexec/crio/pause \
/usr/local/share/man/man5/crio.conf.5 \
/usr/local/share/man/man8/crio.8 \
/etc/crio/crio.conf \
/etc/crio/seccomp.json \
/usr/local/share/oci-umount/oci-umount.d/crio-umount.conf \
/etc/crictl.yaml
# Copy the bits into the second stage of the build.
FROM alpine:latest
WORKDIR /
COPY --from=build /root/crio.tar.gz .
# Set the entrypoint to the bash shell that, by default, pipes
# the above tarball to stdout.
CMD [ "-c", "base64 </crio.tar.gz" ]
ENTRYPOINT [ "/bin/sh" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment