Example Containerfiles simplified to plain FROM + CMD
New example/test.sh for manual verification (needs KVM)
README updated
Verification
cargo check ✓
cargo clippy -- -D warnings ✓
cargo test ✓ (3 passed)
cargo fmt -- --check ✓
``
The `example/test.sh` script tests CMD inference, `slim run --cmd` override, and `slim build --cmd` override for both Alpine and Archlinux (requires podman + QEMU + KVM).
## Summary
slim now works with **any Containerfile** — no more slim-specific init scripts, kernel installs, busybox, or DHCP clients in the Containerfile.
### How it works
`slim build` injects distro-agnostic scripts into the image at `/slim/`:
- **`/slim/init`** — mounts special filesystems (proc, sys, devpts, cgroup2, tmpfs), configures networking (static QEMU slirp: 10.0.2.15/24, gw 10.0.2.2, dns 10.0.2.3), sets timezone, and rootless container prereqs (newuidmap/newgidmap setuid, rshared /). 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 both build and run time.
### Changes
- New `src/inject.rs`: inspect image config, infer command, generate `/slim/exec`, inject `/slim/` into mounted rootfs
- New `src/scripts/slim-init.sh`: universal init script (embedded via `include_str!`)
- `build.rs`: `--init` → `--cmd`, inject before packing, drop `Meta::save`, restructure to always unmount
- `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 (needs KVM)
- README updated
### Verification
```
cargo check ✓
cargo clippy -- -D warnings ✓
cargo test ✓ (3 passed)
cargo fmt -- --check ✓
``
The `example/test.sh` script tests CMD inference, `slim run --cmd` override, and `slim build --cmd` override for both Alpine and Archlinux (requires podman + QEMU + KVM).
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
slim now works with any Containerfile — no more slim-specific init scripts, kernel installs, busybox, or DHCP clients in the Containerfile.
How it works
slim buildinjects distro-agnostic scripts into the image at/slim/:/slim/init— mounts special filesystems (proc, sys, devpts, cgroup2, tmpfs), configures networking (static QEMU slirp: 10.0.2.15/24, gw 10.0.2.2, dns 10.0.2.3), sets timezone, and rootless container prereqs (newuidmap/newgidmap setuid, rshared /). Parsesslim.cmd=<base64>from the kernel cmdline for runtime overrides, otherwise execs/slim/exec./slim/exec— generated from the image's CMD/ENTRYPOINT (viapodman image inspect), overridable via--cmdat both build and run time.Changes
src/inject.rs: inspect image config, infer command, generate/slim/exec, inject/slim/into mounted rootfssrc/scripts/slim-init.sh: universal init script (embedded viainclude_str!)build.rs:--init→--cmd, inject before packing, dropMeta::save, restructure to always unmountqemu.rs: hardcodeinit=/slim/init, add--cmd(base64 on cmdline), dropMeta::load, add-no-rebootsrc/meta.rsandmeta.toml(no longer needed)Cargo.toml: addserde_json+base64, remove unusedwalkdir+cpio+tomlFROM+CMDexample/test.shfor manual verification (needs KVM)Verification
25efbd5f5cto8fdac311608fdac31160to589afef4f5589afef4f5tod52a17fd53d52a17fd53tod528b55473d528b55473tocc2cbd0fb4cc2cbd0fb4to1eed3821721eed382172to8d01d7d3378d01d7d337toc2a9f00fc0