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:
1 parent
1f6d41ab06
commit
0ad5b5f44f
27 files changed
+1108
-45
No files matched your search
@@ -47,6 +47,7 @@ services:
|
||||
STATUS_DIR: /run/status
|
||||
CONTENT_DIR: /content
|
||||
JOBS_FILE: /config/jobs.toml
|
||||
TRIGGER_DIR: /run/jobs/triggers
|
||||
SITE_URL: ${SITE_URL:-https://security-command.org}
|
||||
LEGAL_PAGES: ${LEGAL_PAGES:-impressum:impressum.txt,datenschutz:datenschutz.txt}
|
||||
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-https://security-command.org}
|
||||
@@ -58,6 +59,39 @@ services:
|
||||
- ./runtime/status:/run/status
|
||||
- ${CONTENT_DIR}:/content:ro
|
||||
- ./config:/config:ro
|
||||
- ./runtime/jobs/triggers:/run/jobs/triggers:ro
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 10m
|
||||
max-file: "3"
|
||||
|
||||
jobs:
|
||||
image: ${JOBS_IMAGE:?run deploy.sh}
|
||||
restart: unless-stopped
|
||||
# Jobs run as the owner of the content directory, so they can write into it.
|
||||
user: "${JOBS_USER:?run deploy.sh}"
|
||||
init: true
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp:size=64m
|
||||
cap_drop: [ALL]
|
||||
security_opt: [no-new-privileges:true]
|
||||
mem_limit: 256m
|
||||
pids_limit: 128
|
||||
environment:
|
||||
JOBS_FILE: /config/jobs.toml
|
||||
SCRIPTS_DIR: /jobs
|
||||
CONTENT_DIR: /content
|
||||
HOST_DIR: /host/srv
|
||||
TRIGGER_DIR: /run/jobs/triggers
|
||||
CONTROL_SOCKET: /run/jobs/control.sock
|
||||
volumes:
|
||||
- ${CONTENT_DIR}:/content
|
||||
- ./config:/config
|
||||
- ./jobs:/jobs:ro
|
||||
- ${JOBS_HOST_DIR:-/srv}:/host/srv:ro
|
||||
- ./runtime/jobs:/run/jobs
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
# read it; jobs may write into it.
|
||||
CONTENT_DIR=
|
||||
|
||||
# Host directory job scripts see read only at /host/srv, for example to
|
||||
# describe the services running next to this one.
|
||||
JOBS_HOST_DIR=/srv
|
||||
|
||||
# Public address of the site, used by the sitemap.
|
||||
SITE_URL=https://security-command.org
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Reference for config/jobs.toml. The jobs service creates that file on its
|
||||
# first start with the system jobs, and adds system jobs it lacks on every
|
||||
# start. Edits apply within a second, which restarts all schedules as if the
|
||||
# services had just started.
|
||||
#
|
||||
# Each [[job]] needs exactly one of:
|
||||
# builtin a job implemented in the backend: index, status, reap-orphans
|
||||
# path a script in jobs/, run by the jobs service; it must be executable
|
||||
#
|
||||
# Options:
|
||||
# id lowercase letters, digits and dashes; unique
|
||||
# args list of arguments for the script
|
||||
# every run at a fixed interval: "30s", "15m", "1h", "1d"; at least 1s
|
||||
# cron run on a cron schedule in UTC: "0 4 * * *"
|
||||
# on events: "start", "content-change" (builtin jobs only) and "watch"
|
||||
# watch paths relative to /srv on the host; needs on = ["watch"]. A
|
||||
# directory is watched with everything inside it. The job runs
|
||||
# once things have been quiet for 2s.
|
||||
# then jobs to trigger after a successful run, builtin ones included
|
||||
# timeout run time after which the job is cancelled; default "5m"
|
||||
# env table of extra environment variables
|
||||
# enabled false switches the job off and logs a warning; default true
|
||||
# parallel true lets runs overlap. By default a new trigger cancels the
|
||||
# running run and starts the job over.
|
||||
#
|
||||
# Scripts run as the owner of the content directory with bash, coreutils, curl,
|
||||
# git and jq available, and get these variables:
|
||||
# JOB_ID the id of the job
|
||||
# CONTENT_DIR the content directory, writable
|
||||
# HOST_DIR /srv of the host, read only
|
||||
#
|
||||
# Cancelling sends SIGTERM to the script and everything it started, then
|
||||
# SIGKILL after 5s. Processes a script leaves behind are killed when it exits.
|
||||
#
|
||||
# Manage jobs with jobctl inside the jobs container:
|
||||
# docker exec security-command-jobs-1 jobctl list
|
||||
# docker exec security-command-jobs-1 jobctl run services
|
||||
# docker exec security-command-jobs-1 jobctl cancel services
|
||||
|
||||
# Describes the services next to this one in services/, whenever one of their
|
||||
# compose files changes, and rebuilds the static site right away.
|
||||
[[job]]
|
||||
id = "services"
|
||||
path = "services.sh"
|
||||
on = ["start", "watch"]
|
||||
watch = ["gitea/compose.yml", "nextcloud/compose.yml"]
|
||||
then = ["index"]
|
||||
|
||||
# Mirrors a public repository into the content once a night.
|
||||
[[job]]
|
||||
id = "mirror"
|
||||
path = "mirror.sh"
|
||||
args = ["https://example.org/notes.git", "notes"]
|
||||
cron = "0 4 * * *"
|
||||
timeout = "10m"
|
||||
env = { GIT_TERMINAL_PROMPT = "0" }
|
||||
enabled = false
|
||||
Reference in new issue
Block a user