Inject universal /slim/init instead of requiring container-specific setup
slim now works with any Containerfile by injecting distro-agnostic scripts at build time: - /slim/init: mounts special filesystems, configures networking (static QEMU slirp), sets up cgroup2, timezone, and rootless container prereqs. Parses slim.cmd=<base64> from the kernel cmdline for runtime overrides, otherwise execs /slim/exec. - /slim/exec: generated from the image's CMD/ENTRYPOINT (via podman image inspect), overridable via --cmd at build and run time. Changes: - New src/inject.rs: inspect image config, infer command, generate /slim/exec script, inject /slim/ into mounted rootfs - New src/scripts/slim-init.sh: the universal init script (include_str!) - build.rs: rename --init to --cmd, inject scripts before packing, drop Meta::save, restructure to ensure unmount always runs - qemu.rs: hardcode init=/slim/init, add --cmd (base64 on cmdline), drop Meta::load, add -no-reboot - Remove src/meta.rs and meta.toml (no longer needed) - Cargo.toml: add serde_json + base64, remove unused walkdir + cpio + toml - Example Containerfiles simplified to plain FROM + CMD - New example/test.sh for manual verification - README updated for new workflow
This commit was merged in pull request #6.
This commit is contained in:
@@ -1,23 +1,2 @@
|
||||
# FROM archlinux:latest
|
||||
FROM marvin
|
||||
|
||||
|
||||
USER root
|
||||
|
||||
# Update, install kernel, initramfs tools, and utilities
|
||||
# 'linux' includes mkinitcpio hooks that auto-generate the initramfs
|
||||
RUN pacman -Syu --noconfirm linux busybox util-linux dhcpcd; \
|
||||
pacman -Sc --noconfirm
|
||||
|
||||
# Copy kernel and initramfs to root for VM extraction
|
||||
RUN cp /boot/vmlinuz-linux /vmlinuz && \
|
||||
cp /boot/initramfs-linux.img /initrd.img
|
||||
|
||||
# Allow root login without password
|
||||
RUN passwd -d root
|
||||
|
||||
# Set up timezone. Required to bypass archlinux's first-install setup.
|
||||
RUN ln -s /usr/share/zoneinfo/Europe/Stockholm /etc/localtime
|
||||
|
||||
COPY init /init
|
||||
RUN chmod +x /init
|
||||
FROM archlinux:latest
|
||||
CMD ["/bin/sh"]
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Mount special filesystems
|
||||
mkdir -p /dev /proc /sys
|
||||
[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
|
||||
mount -t proc proc /proc
|
||||
mount -t sysfs sysfs /sys
|
||||
|
||||
# Networking
|
||||
echo slim > /proc/sys/kernel/hostname
|
||||
ip link set lo up 2>/dev/null
|
||||
ip link set eth0 up 2>/dev/null
|
||||
# udhcpc -i eth0 -f -q # Get DHCP lease
|
||||
|
||||
echo
|
||||
echo 'Welcome to slim!'
|
||||
echo
|
||||
|
||||
# Start systemd
|
||||
exec /sbin/init
|
||||
|
||||
# Or, just run a shell
|
||||
# /bin/sh </dev/console >/dev/console 2>&1
|
||||
# poweroff -f
|
||||
# while true; do
|
||||
# sleep 1
|
||||
# poweroff -f
|
||||
# done
|
||||
Reference in New Issue
Block a user