Skip to content

Commit d4ff284

Browse files
committed
Use libcontainer for running containers
Drop the dependency on container engines like Docker or Podman by using youki's `libcontainer` and `oci-spec` crates to run rootless containers, while keeping all the logic doing that in our binary. That solves the major problem we had with Docker - file ownership in bind mounted volumes - where new files created inside container in a volume with source code were owned by `root` and therefore inaccessible for a regular user calling `icedragon`. After this change, regular container engines are still used for building the images. Fixes #7
1 parent f186b3d commit d4ff284

File tree

4 files changed

+531
-304
lines changed

4 files changed

+531
-304
lines changed

.github/workflows/ci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ jobs:
7979
- uses: actions/checkout@v4
8080
- uses: dtolnay/rust-toolchain@stable
8181

82+
# AppArmor, which is used on GitHub runners, prevents icedragon from
83+
# calling `unshare` as an unprivileged used.
84+
# TODO(vadorovsky): Write an AppArmor profile.
85+
- run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
86+
8287
# Integration tests perform cross builds of different projects. Run each
8388
# of them separately, so each build can utilize all the cores. Gather
8489
# their output for easier debugging of failed CI builds.

Cargo.toml

+18-1
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,38 @@ anyhow = { version = "1.0.89", default-features = false }
2323
chrono = { version = "0.4", default-features = false }
2424
clap = { version = "4.5", default-features = false, features = ["derive", "help", "std"] }
2525
env_logger = { version = "0.11", default-features = false }
26+
flate2 = { version = "1.0", default-features = false, features = ["rust_backend"] }
27+
indicatif = { version = "0.17", default-features = false }
28+
libcontainer = { version = "0.5", default-features = false, features = ["v2"] }
2629
log = { version = "0.4", default-features = false }
30+
nix = { version = "0.29.0", default-features = false }
31+
oci-client = { version = "0.14", default-features = false, features = ["rustls-tls"] }
32+
# libcontainer fails to build with newer versions. Not a direct dependency of
33+
# icedragon.
34+
protobuf = "=3.2.0"
35+
rand = { version = "0.9", default-features = false, features = ["os_rng", "std_rng"] }
2736
target-lexicon = { version = "0.12", default-features = false }
37+
tar = { version = "0.4", default-features = false }
2838
thiserror = { version = "1.0.64", default-features = false }
39+
tokio = { version = "1.44", default-features = false, features = ["process", "rt-multi-thread"] }
40+
tokio-stream = { version = "0.1", default-features = false }
2941
uuid = { version = "1.10", default-features = false, features = ["v4"] }
3042
which = { version = "6.0", default-features = false }
3143

3244
[dev-dependencies]
33-
flate2 = { version = "1.0", default-features = false, features = ["rust_backend"] }
3445
goblin = { version = "0.9", default-features = false, features = ["elf32", "elf64", "endian_fd", "std"] }
3546
liblzma = { version = "0.3", default-features = false }
3647
reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"] }
3748
tar = { version = "0.4", default-features = false }
3849
tempfile = { version = "3.16", default-features = false }
3950
test-case = { version = "3.3", default-features = false }
4051

52+
[patch.crates-io]
53+
# Fix which makes it possible to use rootless libcontainer without systemd:
54+
# https://github.com/youki-dev/youki/issues/3144
55+
# https://github.com/youki-dev/youki/pull/3146
56+
libcontainer = { git = "https://github.com/vadorovsky/youki", branch = "cgroupfs-rootless-warning" }
57+
4158
[[bin]]
4259
name = "icedragon"
4360

0 commit comments

Comments
 (0)