Initial commit: Gitea CI jobs in gVisor with sandboxed Docker
This commit is contained in:
commit
6c14f5d76d
17 files changed
+1084
No files matched your search
@@ -0,0 +1,52 @@
|
||||
name: gvisor-isolation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
# This label is mapped in runner/config.yaml to alpine:3.20. Every job
|
||||
# container is created by the nested dockerd with default-runtime=runsc.
|
||||
runs-on: gvisor
|
||||
steps:
|
||||
- name: Prove the job runs on the gVisor kernel
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
echo "uname: $(uname -a)"
|
||||
echo "proc/version: $(cat /proc/version)"
|
||||
grep -qi gvisor /proc/version
|
||||
echo "OK: workflow is running inside gVisor"
|
||||
|
||||
- name: The privileged runner socket is hidden; only the sandboxed daemon is reachable
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
if [ -S /var/run/docker.sock ]; then
|
||||
echo "ERROR: the privileged runner Docker socket leaked into the job" >&2
|
||||
exit 1
|
||||
fi
|
||||
# TCP 2375 belongs to the separate gVisor-sandboxed Docker daemon.
|
||||
test "$(wget -qO- --timeout=5 http://127.0.0.1:2375/_ping)" = "OK"
|
||||
echo "OK: privileged socket hidden; sandboxed Docker daemon is reachable"
|
||||
|
||||
- name: Prove service DNS and network access work
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
wget -qO- --timeout=10 http://gitea:3000/api/healthz >/dev/null
|
||||
echo "OK: the job can reach Gitea by service name"
|
||||
|
||||
- name: Prove the outer Docker host API is not reachable
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
gateway=$(ip route | awk '/^default / {print $3; exit}')
|
||||
echo "gateway=${gateway}"
|
||||
if wget -qO- --timeout=3 "http://${gateway}:2375/version" >/dev/null 2>&1; then
|
||||
echo "ERROR: the outer Docker host API is reachable from the job" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "OK: outer Docker host API blocked; Gitea/internet still work"
|
||||
Reference in new issue
Block a user