furtka/ops/forgejo-runner/bootstrap.sh
Daniel Maksymilian Syrnicki 6cf65f2c36
Some checks failed
CI / lint (push) Successful in 1m12s
CI / test (push) Successful in 32s
CI / validate-json (push) Successful in 22s
CI / markdown-links (push) Failing after 2s
ci: stand up forge-runner-01 with DinD sidecar, fix doc label bug
Bootstrap script + compose + config checked in under ops/forgejo-runner/
so a second runner is a scripted setup. runner-setup.md corrects the
register label format (<name>:docker://<image>, not bare names) and
documents the Ubuntu systemd-resolved DNS gotcha.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 21:31:35 +02:00

43 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Install Docker Engine + Compose plugin on a fresh Ubuntu 24.04 VM
# and prepare it to host a Forgejo Actions runner.
#
# Run as the target user (needs sudo). Idempotent.
set -euo pipefail
if [[ "$(. /etc/os-release && echo "$ID")" != "ubuntu" ]]; then
echo "This script targets Ubuntu. Aborting." >&2
exit 1
fi
echo "==> Updating apt and installing prerequisites"
sudo apt-get update -y
sudo apt-get install -y ca-certificates curl gnupg
echo "==> Adding Docker's official GPG key"
sudo install -m 0755 -d /etc/apt/keyrings
if [[ ! -f /etc/apt/keyrings/docker.asc ]]; then
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
fi
echo "==> Adding Docker apt repository"
ARCH="$(dpkg --print-architecture)"
CODENAME="$(. /etc/os-release && echo "$VERSION_CODENAME")"
echo "deb [arch=${ARCH} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${CODENAME} stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo "==> Installing Docker Engine + Compose plugin"
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
echo "==> Adding $USER to docker group"
sudo usermod -aG docker "$USER"
echo "==> Enabling docker service"
sudo systemctl enable --now docker
echo
echo "Done. Log out and back in (or run 'newgrp docker') so group membership takes effect."
docker --version
docker compose version