Skip to content

A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.

build(rootfs): cross-compile podroid-vsock-agent into the squashfs

ExTv7383f8f82ab7
diff --git a/build-rootfs/Dockerfile.rootfs b/build-rootfs/Dockerfile.rootfs
index 79bd409..6f7fa00 100644
--- a/build-rootfs/Dockerfile.rootfs
+++ b/build-rootfs/Dockerfile.rootfs
@@ -1,4 +1,14 @@
# build-rootfs/Dockerfile.rootfs
+
+# ── Stage 1: cross-compile podroid-vsock-agent (musl-static aarch64) ────────
+# Uses qemu-user under the hood — no separate cross-toolchain needed.
+FROM --platform=linux/arm64 alpine:3.23 AS vsock-builder
+RUN apk add --no-cache musl-dev gcc make linux-headers
+WORKDIR /work
+COPY vsock-agent /work/vsock-agent
+RUN cd /work/vsock-agent && make CC=gcc
+
+# ── Stage 2: build the Alpine rootfs squashfs ───────────────────────────────
FROM alpine:3.23 AS builder
ARG ALPINE_RELEASE=3.23.4
@@ -13,6 +23,9 @@ RUN curl -L -o minirootfs.tar.gz \
&& tar -xzf minirootfs.tar.gz -C rootfs \
&& rm minirootfs.tar.gz
+# Pull in the vsock-agent binary built in stage 1.
+COPY --from=vsock-builder /work/vsock-agent/podroid-vsock-agent /work/rootfs/usr/local/bin/podroid-vsock-agent
+
ENV ALPINE_VERSION=${ALPINE_RELEASE}
COPY files /work/files
COPY build-rootfs.sh /work/build-rootfs.sh
diff --git a/build-rootfs/build-rootfs.sh b/build-rootfs/build-rootfs.sh
index 9c5261e..be84e42 100755
--- a/build-rootfs/build-rootfs.sh
+++ b/build-rootfs/build-rootfs.sh
@@ -100,6 +100,10 @@ mkdir -p "$ROOTFS/usr/local/bin"
cp /work/files/usr/local/bin/podroid-resize "$ROOTFS/usr/local/bin/"
cp /work/files/usr/local/bin/podroid-login "$ROOTFS/usr/local/bin/"
cp /work/files/usr/local/bin/podroid-getty "$ROOTFS/usr/local/bin/"
+# podroid-vsock-agent is COPY'd in from the vsock-builder Docker stage. Make
+# sure it's executable (cross-arch COPY can lose the mode bit on some buildkit
+# versions).
+chmod +x "$ROOTFS/usr/local/bin/podroid-vsock-agent" 2>/dev/null || true
chmod +x "$ROOTFS/usr/local/bin/podroid-"*
mkdir -p "$ROOTFS/etc/conf.d"
cp /work/files/etc/conf.d/podroid "$ROOTFS/etc/conf.d/"