Add jobs service with script execution, configuration support, and control interface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OverlordandClaude Bot committed 2026-10-13 15:04:21 +02:00
1 parent 1f6d41ab06
commit 0ad5b5f44f
27 files changed
+1108 -45

No files matched your search

+16 -2
View File
@@ -47,6 +47,13 @@ if [[ ! -d ${CONTENT_DIR:-} || ${CONTENT_DIR} != /* ]]; then
exit 1
fi
# Jobs run as the owner of the content directory, which must not be root.
jobs_user=$(stat -c %u:%g "$CONTENT_DIR")
if [[ ${jobs_user%%:*} == 0 ]]; then
echo "CONTENT_DIR is owned by root; give it to the user that maintains the content, jobs run as that user" >&2
exit 1
fi
registry_host=${REGISTRY%%/*}
if ! grep -qs "\"${registry_host}\"" ~/.docker/config.json; then
echo "log in to the registry first: docker login ${registry_host} (token with read:package)" >&2
@@ -75,20 +82,26 @@ commit=$(as_owner git rev-parse HEAD)
sandbox_tag="${REGISTRY}/homepage-sandbox:${commit}"
spawner_tag="${REGISTRY}/homepage-spawner:${commit}"
backend_tag="${REGISTRY}/homepage-backend:${commit}"
jobs_tag="${REGISTRY}/homepage-jobs:${commit}"
pull_image sandbox_docker "$sandbox_tag"
pull_image docker "$spawner_tag"
pull_image docker "$backend_tag"
pull_image docker "$jobs_tag"
digest() { "$1" image inspect --format '{{index .RepoDigests 0}}' "$2"; }
# The spawner runs as 10001 and shares group 10100 with the backend, which
# runs as 10002 and writes the status file that sandboxes read.
install -d -m 0755 runtime config jobs
# runs as 10002 and writes the status file that sandboxes read. The jobs
# service writes the job file and the triggers the backend reads.
install -d -m 0755 runtime
install -d -o 10001 -g 10100 -m 0750 runtime/spawner
install -d -o 10002 -g 10002 -m 0755 runtime/status
install -d -o "${jobs_user%%:*}" -g "${jobs_user##*:}" -m 0755 config jobs runtime/jobs runtime/jobs/triggers
cat > runtime/deploy.env <<EOF
SANDBOX_IMAGE=$(digest sandbox_docker "$sandbox_tag")
SPAWNER_IMAGE=$(digest docker "$spawner_tag")
BACKEND_IMAGE=$(digest docker "$backend_tag")
JOBS_IMAGE=$(digest docker "$jobs_tag")
JOBS_USER=${jobs_user}
SANDBOX_GROUP_ID=$(getent group sandbox-spawner | cut -d: -f3)
STATUS_DIR=${PWD}/runtime/status
EOF
@@ -102,3 +115,4 @@ docker compose --project-directory "$PWD" -f deploy/compose.yml \
--env-file .env --env-file runtime/deploy.env up -d --remove-orphans
echo "deployed ${commit}"
echo "jobs: docker exec security-command-jobs-1 jobctl list"