aboutsummaryrefslogtreecommitdiff
path: root/container
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2026-09-11 15:54:00 +0200
committerNicholas Rodrigues Lordello <[email protected]>2026-09-11 16:16:28 +0200
commitd893a0e08fbf0ae7fc85b62a0814ab31d758169a (patch)
tree3ae526e4cead6a39ae1744780e2838dfd15e05ba /container
parent1c46b80e3a4c2064d1ce8b818463ae7daf08183f (diff)
Implement Basic RC System
We added a basic RC system (that runs executable scripts from a directory in the container) for greater customization. Additionally, the post-installation script now runs as root (as it alwasy should have) to allow for additional customization of the enviroment before dropping to the user. This allows for some more complicated devbox provisioning such as: - Making /dev/net/tun accessible to the developement user for pasta - Support setting up XDG runtime dirs if required In particular, this supports a case for running `podman` within the `krun` container: `podman`'s overlay storage driver does not work on `virtiofs` file systems, this allows you to create a loop-mount for `podman` storage to work around this issue. ```sh truncate -s 32G /var/lib/user.img mkfs.ext4 /var/lib/user.img mkdir -p /var/lib/user USER="$1" UID="$(id -u "$USER")" GID="$(id -g "$USER")" cat <<EOF >/etc/dbx/rc.d/user-dirs.sh mountpoint -q /var/lib/user || mount -o loop /var/lib/user.img /var/lib/user install -d -m 0755 -o '$UID' -g '$GID' '/var/lib/user/$UID' install -d -m 0700 -o '$UID' -g '$GID' '/run/user/$UID' EOF ``` For obvious reasons, you do not want the 32GB image to be included in the devbox image. This allows ths user to use `/var/lib/user/1000/...` as `podman` graphroot storage: ```toml [storage] driver = "overlay" graphroot = "/var/lib/user/1000/containers/storage" ```
Diffstat (limited to 'container')
-rw-r--r--container/Containerfile1
-rwxr-xr-xcontainer/init7
2 files changed, 8 insertions, 0 deletions
diff --git a/container/Containerfile b/container/Containerfile
index e8f8670..f7fc00f 100644
--- a/container/Containerfile
+++ b/container/Containerfile
@@ -41,5 +41,6 @@ RUN echo "StreamLocalBindUnlink yes" >> /etc/ssh/sshd_config && \
touch /etc/ssh/authorized_keys
# Set up the entrypoint
+RUN mkdir -p /etc/dbx/rc.d
COPY init /sbin/init
ENTRYPOINT ["/sbin/init"]
diff --git a/container/init b/container/init
index 24b6629..49ee840 100755
--- a/container/init
+++ b/container/init
@@ -7,4 +7,11 @@ if [ ! -f /run/.dbxenv ]; then
exit 1
fi
+for rc in /etc/dbx/rc.d/*; do
+ if [ ! -f "$rc" ] || [ ! -x "$rc" ]; then
+ continue
+ fi
+ "$rc" || printf '%s: %s failed (%d)\n' "$0" "$rc" "$?" >&2
+done
+
exec /usr/bin/tini /usr/sbin/sshd -- -D -e