blumeops/containers/forgejo-runner/entrypoint.sh
Erich Blume 008533491f
Some checks failed
Build Container / build (push) Failing after 41s
Add containerized forgejo-runner for Phase 1 ratcheting
Part of the runner ratcheting plan to migrate from host-mode to k8s runners.

- Debian-based image with forgejo-runner and Docker CLI
- Mounts Docker socket for container builds
- Auto-registers on first start
- Host networking for access to *.ops.eblu.me services

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 17:21:29 -08:00

36 lines
1.2 KiB
Bash

#!/bin/bash
# Forgejo Runner entrypoint script
#
# Registers the runner on first start, then runs the daemon.
# State is persisted in /data so restarts don't re-register.
set -e
# Required environment variables
: "${FORGEJO_URL:?FORGEJO_URL is required (e.g., https://forge.ops.eblu.me)}"
: "${RUNNER_TOKEN:?RUNNER_TOKEN is required (from Forgejo admin > Actions > Runners)}"
# Optional environment variables with defaults
RUNNER_NAME="${RUNNER_NAME:-forgejo-runner}"
RUNNER_LABELS="${RUNNER_LABELS:-docker:docker://debian:bookworm-slim}"
# Registration file indicates runner is already registered
RUNNER_FILE="/data/.runner"
# Register if not already registered
if [ ! -f "$RUNNER_FILE" ]; then
echo "Registering runner '${RUNNER_NAME}' with ${FORGEJO_URL}..."
forgejo-runner register \
--instance "${FORGEJO_URL}" \
--token "${RUNNER_TOKEN}" \
--name "${RUNNER_NAME}" \
--labels "${RUNNER_LABELS}" \
--no-interactive
echo "Registration complete."
else
echo "Runner already registered, skipping registration."
fi
# Start the runner daemon
echo "Starting forgejo-runner daemon..."
exec forgejo-runner daemon --config /etc/forgejo-runner/config.yaml