penguin/monok8s

k8s image for Mono Gateway Dev Kit

commit 3e6df38f458f4593f4a3a469ab1756a30bf32c43e354a347cb403f9c64ddee22

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-04-01T11:28:42Z
subjectSlightly simplify the build
commit 3e6df38f458f4593f4a3a469ab1756a30bf32c43e354a347cb403f9c64ddee22
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-04-01T11:28:42Z

    Slightly simplify the build
---
 .dockerignore                  | 2 ++
 alpine/build-rootfs.sh         | 3 ++-
 alpine/install-packages.sh     | 9 +++++++++
 docker/alpine.Dockerfile       | 7 ++++---
 docker/build-base.Dockerfile   | 1 +
 docker/kernel-build.Dockerfile | 3 ++-
 6 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..7040a2f
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+out/*.img.gz
+out/*.ext4.zst
diff --git a/alpine/build-rootfs.sh b/alpine/build-rootfs.sh
index a57e359..9b19d8d 100755
--- a/alpine/build-rootfs.sh
+++ b/alpine/build-rootfs.sh
@@ -4,6 +4,8 @@ set -euo pipefail
 
 /preload-k8s-images.sh || exit 1
 
+export CTL_BIN_LAYER=$( skopeo inspect docker-daemon:localhost/monok8s/control-agent:dev | jq -r '.Layers[0] | sub("^sha256:"; "")' )
+
 mkdir -p "$ROOTFS/var/cache/apk"
 mkdir -p "$ROOTFS/opt/monok8s/config"
 mkdir -p "$ROOTFS/build"
@@ -25,7 +27,6 @@ mount --bind /run  "$ROOTFS/run"
 cp /usr/bin/qemu-aarch64-static "$ROOTFS/usr/bin/"
 cp /etc/resolv.conf "$ROOTFS/etc/resolv.conf"
 cp /build/crio.tar.gz "$ROOTFS/build/"
-cp -r /build/rootfs/* "$ROOTFS/"
 
 chroot "$ROOTFS" /bin/sh -c "ln -s /var/cache/apk /etc/apk/cache"
 # chroot "$ROOTFS" /bin/sh -c "apk update"
diff --git a/alpine/install-packages.sh b/alpine/install-packages.sh
index c69865c..8c9ba6c 100755
--- a/alpine/install-packages.sh
+++ b/alpine/install-packages.sh
@@ -34,6 +34,15 @@ fi
 sed -i "s/default_runtime = \"crun\"/\0\ncgroup_manager = \"cgroupfs\"/g" /etc/crio/crio.conf.d/10-crio.conf
 grep cgroup_manager /etc/crio/crio.conf.d/10-crio.conf || exit 1
 
+echo "##################################################### Installing Control Agent"
+CTL_BIN=$(find /usr/lib/monok8s/imagestore -name "ctl" | grep "$CTL_BIN_LAYER")
+if [ -z "$CTL_BIN" ]; then
+	echo "Unable to locate the control agent binary"
+	exit 1
+fi
+ln -s "$CTL_BIN" /usr/local/bin/ctl
+
+
 mkdir -p /var/run/crio
 mkdir -p /var/lib/containers/storage
 mkdir -p /var/lib/cni
diff --git a/docker/alpine.Dockerfile b/docker/alpine.Dockerfile
index 3ca42a2..858e3b5 100644
--- a/docker/alpine.Dockerfile
+++ b/docker/alpine.Dockerfile
@@ -15,17 +15,18 @@ RUN mkdir -p "/out/rootfs"
 COPY packages/alpine-minirootfs-${ALPINE_VER}-${ALPINE_ARCH}.tar.gz ./alpine.tar.gz
 COPY packages/${CRIO_VERSION}.tar.gz ./crio.tar.gz
 COPY out/board.itb ./
-COPY out/rootfs ./rootfs
+COPY out/rootfs.tar.gz ./rootfs.tar.gz
 COPY out/${DEVICE_TREE_TARGET}.dtb ./
 COPY out/Image.gz ./
 
-RUN tar -xf alpine.tar.gz -C "/out/rootfs"
+RUN tar zxf rootfs.tar.gz -C "/out"
+RUN tar zxf alpine.tar.gz -C "/out/rootfs"
 
 RUN mkdir -p /out/rootfs/usr/local/bin/
 COPY packages/kubernetes/kubelet-${KUBE_VERSION} /out/rootfs/usr/local/bin/kubelet
 COPY packages/kubernetes/kubeadm-${KUBE_VERSION} /out/rootfs/usr/local/bin/kubeadm
 COPY packages/kubernetes/kubectl-${KUBE_VERSION} /out/rootfs/usr/local/bin/kubectl
-COPY clitools/bin/ctl-linux-${ALPINE_ARCH}-${TAG} /out/rootfs/usr/local/bin/ctl
+# COPY clitools/bin/ctl-linux-${ALPINE_ARCH}-${TAG} /out/rootfs/usr/local/bin/ctl
 RUN chmod +x /out/rootfs/usr/local/bin/*
 
 COPY alpine/rootfs-extra ./rootfs-extra
diff --git a/docker/build-base.Dockerfile b/docker/build-base.Dockerfile
index 264e3e3..656e670 100644
--- a/docker/build-base.Dockerfile
+++ b/docker/build-base.Dockerfile
@@ -21,6 +21,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
     flex \
     git \
     gettext-base \
+	jq \
     kmod \
     libelf-dev \
     libssl-dev \
diff --git a/docker/kernel-build.Dockerfile b/docker/kernel-build.Dockerfile
index 39d4d86..9673b6f 100644
--- a/docker/kernel-build.Dockerfile
+++ b/docker/kernel-build.Dockerfile
@@ -47,6 +47,7 @@ RUN depmod -b /out/rootfs $(ls /out/rootfs/lib/modules/)
 
 RUN find /out/kernel -name "${DEVICE_TREE_TARGET}.dtb" -exec cp {} /out/ \;
 RUN test -f "/out/${DEVICE_TREE_TARGET}.dtb"
+RUN cd /out && tar zcf rootfs.tar.gz rootfs
 
 FROM scratch
 ARG DEVICE_TREE_TARGET
@@ -57,4 +58,4 @@ COPY --from=build \
 	/out/kernel/Image.gz \
 	/out/${DEVICE_TREE_TARGET}.dtb \
 	./
-COPY --from=build /out/rootfs/ ./rootfs
+COPY --from=build /out/rootfs.tar.gz ./rootfs.tar.gz