Skip to content

Commit

Permalink
CI: add nerdctl
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Aug 18, 2024
1 parent 635c2c4 commit f46b880
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
engine: [docker, podman]
engine: [docker, nerdctl, podman]
env:
CONTAINER_ENGINE: "${{ matrix.engine }}"
steps:
Expand All @@ -37,6 +37,13 @@ jobs:
sudo rm -rf /var/run/docker*
dockerd-rootless-setuptool.sh install
docker info
- name: Set up Rootless nerdctl
if: ${{ matrix.engine == 'nerdctl' }}
run: |
set -eux -o pipefail
sudo ./init-host/init-host.root.d/install-nerdctl.sh
./init-host/init-host.rootless.sh
nerdctl info
- name: Set up Rootless Podman
if: ${{ matrix.engine == 'podman' }}
run: |
Expand Down Expand Up @@ -68,6 +75,8 @@ jobs:
include:
- lxc-image: ubuntu:24.04
engine: docker
- lxc-image: ubuntu:24.04
engine: nerdctl
# LXD is now banned from pulling images:fedora from https://images.linuxcontainers.org/
# TODO: switch away from LXD to Incus: https://github.com/rootless-containers/usernetes/pull/332
# - lxc-image: images:fedora/39/cloud
Expand Down
40 changes: 40 additions & 0 deletions init-host/init-host.root.d/install-nerdctl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -eux -o pipefail
if [ "$(id -u)" != "0" ]; then
echo "Must run as the root"
exit 1
fi

VERSION="2.0.0-rc.1"
SHASHA="7086527171059921baf076ec0111881c6f411ff0b672623e7cb4bb69fd93226c"

arch=""
case "$(uname -m)" in
"x86_64")
arch="amd64"
;;
"aarch64")
arch="arm64"
;;
*)
echo >&2 "Unsupported architecture"
exit 1
;;
esac

mkdir -p /root/nerdctl.tmp
(
cd /root/nerdctl.tmp
curl -fSLO https://github.com/containerd/nerdctl/releases/download/v${VERSION}/nerdctl-full-${VERSION}-linux-${arch}.tar.gz
curl -fSLO https://github.com/containerd/nerdctl/releases/download/v${VERSION}/SHA256SUMS
[ "$(sha256sum SHA256SUMS | awk '{print $1}')" = "${SHASHA}" ]
sha256sum --check --ignore-missing SHA256SUMS
tar Cxzvvf /usr/local nerdctl-full-${VERSION}-linux-${arch}.tar.gz
)
rm -rf /root/nerdctl.tmp

if [ -e /etc/apparmor.d/rootlesskit ]; then
# https://rootlesscontaine.rs/getting-started/common/apparmor/
sed -e s@/usr/bin/rootlesskit@/usr/local/bin/rootlesskit@g /etc/apparmor.d/rootlesskit >/etc/apparmor.d/usr.local.bin.rootlesskit
systemctl restart apparmor
fi
6 changes: 3 additions & 3 deletions init-host/init-host.root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ case "${CONTAINER_ENGINE}" in
fi
systemctl disable --now docker
;;
"podman")
if ! command -v podman >/dev/null 2>&1; then
"${script_dir}"/init-host.root.d/install-podman.sh
"podman" | "nerdctl")
if ! command -v "${CONTAINER_ENGINE}" >/dev/null 2>&1; then
"${script_dir}"/init-host.root.d/install-"${CONTAINER_ENGINE}".sh
fi
;;
*)
Expand Down
5 changes: 5 additions & 0 deletions init-host/init-host.rootless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ case "${CONTAINER_ENGINE}" in
"docker")
dockerd-rootless-setuptool.sh install || (journalctl --user --since "10 min ago"; exit 1)
;;
"nerdctl")
containerd-rootless-setuptool.sh install
containerd-rootless-setuptool.sh install-buildkit-containerd
containerd-rootless-setuptool.sh install-bypass4netnsd
;;
"podman")
systemctl --user enable --now podman-restart
;;
Expand Down

0 comments on commit f46b880

Please sign in to comment.