Initial sandbox infrastructure setup.

This commit is contained in:
Overlord committed 2026-10-12 21:00:12 +02:00
1 parent 6ac68a7025
commit 0737b28897
10 files changed
+262

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Prepares the host for sandbox sessions: installs gVisor, creates the
# spawner account and starts the dedicated sandbox Docker daemon.
# Run as root from the repository root. Safe to run repeatedly.
set -euo pipefail
if [[ $EUID -ne 0 ]]; then
echo "run as root" >&2
exit 1
fi
repo_root=$(cd "$(dirname "$0")/../.." && pwd)
if ! command -v runsc >/dev/null; then
apt-get update
apt-get install -y curl gnupg
curl -fsSL https://gvisor.dev/archive.key \
| gpg --dearmor --yes -o /usr/share/keyrings/gvisor-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/gvisor-archive-keyring.gpg] https://storage.googleapis.com/gvisor/releases release main" \
> /etc/apt/sources.list.d/gvisor.list
apt-get update
apt-get install -y runsc
fi
getent group sandbox-spawner >/dev/null || groupadd --system sandbox-spawner
id sandbox-spawner >/dev/null 2>&1 \
|| useradd --system --gid sandbox-spawner --no-create-home --shell /usr/sbin/nologin sandbox-spawner
install -D -m 0644 "$repo_root/deploy/docker-sandbox/daemon.json" /etc/docker-sandbox/daemon.json
install -m 0644 "$repo_root/deploy/systemd/sandbox.slice" /etc/systemd/system/sandbox.slice
install -m 0644 "$repo_root/deploy/systemd/docker-sandbox.service" /etc/systemd/system/docker-sandbox.service
systemctl daemon-reload
systemctl start sandbox.slice
systemctl enable docker-sandbox.service
systemctl restart docker-sandbox.service
echo "sandbox daemon is up: DOCKER_HOST=unix:///run/docker-sandbox/docker.sock docker info"