18 lines
1.1 KiB
Django/Jinja
18 lines
1.1 KiB
Django/Jinja
[Unit]
|
|
Description=Docker prune for Gitea runner resources
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
Environment=DOCKER_HOST=unix:///run/user/{{ gitea_runner_uid }}/docker.sock
|
|
Environment=XDG_RUNTIME_DIR=/run/user/{{ gitea_runner_uid }}
|
|
# Force-remove stale containers (including running ones) left behind by failed
|
|
# molecule tests. "docker container prune -f" only removes stopped containers,
|
|
# so running containers from crashed/interrupted CI jobs accumulate indefinitely,
|
|
# consuming disk and memory. We stop+rm everything first, then prune the rest.
|
|
# Exclude CI job containers (name starts with GITEA-ACTIONS-TASK) — removing
|
|
# them kills the active CI job and causes "RWLayer is unexpectedly nil" errors.
|
|
ExecStart=/bin/sh -c 'docker ps -a --format "{% raw %}{{.ID}} {{.Names}}{% endraw %}" 2>/dev/null | grep -v "GITEA-ACTIONS-TASK" | awk "{print $1}" | xargs -r docker rm -f 2>/dev/null || true'
|
|
ExecStart=/usr/bin/docker system prune -af --filter "until={{ gitea_runner_prune_until }}" --volumes
|
|
ExecStart=/usr/bin/docker network prune -f
|
|
ExecStart=/usr/bin/docker builder prune -f
|