#!/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 # arp-scan + iputils: needed by scripts/smoke-vm.sh for MAC→IP discovery # of the test VM on the Proxmox test host (live ISO has no guest agent, # so we scan the LAN and match on the MAC we assigned at VM creation). sudo apt-get install -y ca-certificates curl gnupg arp-scan iputils-arping 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