Add deploy script and CI workflow for sandboxed homepage deployment.
This commit is contained in:
1 parent
0737b28897
commit
571f43457d
5 files changed
+142
-12
No files matched your search
@@ -0,0 +1,5 @@
|
||||
# Absolute host path of the homepage content. It is mounted read only.
|
||||
CONTENT_DIR=
|
||||
|
||||
# Container registry of the SecurityCommand organization.
|
||||
REGISTRY=git.security-command.org/securitycommand
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/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.
|
||||
# spawner group and runs the dedicated sandbox Docker daemon.
|
||||
# Called by deploy.sh as root. Safe to run repeatedly: the sandbox daemon
|
||||
# only restarts when its configuration changed, so live sessions survive.
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
@@ -23,16 +24,26 @@ if ! command -v runsc >/dev/null; then
|
||||
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
|
||||
changed=0
|
||||
install_if_changed() {
|
||||
if ! cmp -s "$1" "$2"; then
|
||||
install -D -m 0644 "$1" "$2"
|
||||
changed=1
|
||||
fi
|
||||
}
|
||||
|
||||
systemctl daemon-reload
|
||||
install_if_changed "$repo_root/deploy/docker-sandbox/daemon.json" /etc/docker-sandbox/daemon.json
|
||||
install_if_changed "$repo_root/deploy/systemd/sandbox.slice" /etc/systemd/system/sandbox.slice
|
||||
install_if_changed "$repo_root/deploy/systemd/docker-sandbox.service" /etc/systemd/system/docker-sandbox.service
|
||||
|
||||
if [[ $changed == 1 ]]; then
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
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"
|
||||
systemctl enable --quiet docker-sandbox.service
|
||||
if [[ $changed == 1 ]]; then
|
||||
systemctl restart docker-sandbox.service
|
||||
else
|
||||
systemctl start docker-sandbox.service
|
||||
fi
|
||||
Reference in new issue
Block a user