Page MenuHomeSealhub

Cloud Init Forgejo worker
ActivePublic

Authored by cichy1173 on Dec 12 2025, 17:21.
Project Tags
None
Referenced Files
F15578195: Cloud Init Forgejo worker
Dec 12 2025, 17:21
Subscribers
None
cloud-config
package_update: true
packages:
- qemu-guest-agent
- sudo
- lsb-release
- curl
- gnupg
- apt-transport-https
- make
- mc
- net-tools
- lsof
- htop
- cron
- jq
- zip
- telnet
- ca-certificates
write_files:
- path: /usr/local/bin/init.sh
content: |
#!/usr/bin/env bash
set -xe
export RUNNER_VERSION=$(curl -X 'GET' https://code.forgejo.org/api/v1/repos/forgejo/runner/releases/latest | jq .name -r | cut -c 2-)
wget -O /home/${USERNAME}/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v$RUNNER_VERSION/forgejo-runner-$RUNNER_VERSION-linux-amd64
chmod +x /home/${USERNAME}/forgejo-runner
cd /home/${USERNAME} && ./forgejo-runner register --no-interactive --token ${CODEBERG_TOKEN} --name ${RUNNER_NAME} --instance https://codeberg.org
./forgejo-runner generate-config > /home/${USERNAME}/config.yml
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt -y update
sudo apt -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
usermod -aG docker ${USERNAME}
export dockerID=$(id | grep -Po '\d+(?=\(docker\))' | head -1)
docker run -d -v /var/run/docker.sock:/var/run/docker.sock --user 1000:$dockerID -v $PWD:/data --rm code.forgejo.org/forgejo/runner:$RUNNER_VERSION forgejo-runner --config config.yml daemon
curl -fsSL https://tailscale.com/install.sh | sh && sudo tailscale up --auth-key=${TAILNET_KEY}
# Create the systemd service file
cat > /etc/systemd/system/frogejorunnerservice.service << 'EOF'
[Unit]
Description=Forgejo CI Runner Listening Service
After=network.target
[Service]
Type=simple
User=${USERNAME}
WorkingDirectory=/home/${USERNAME}
ExecStart=/home/${USERNAME}/forgejo-runner --config /home/${USERNAME}/config.yml daemon
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
# Enable and start the service
systemctl daemon-reload
systemctl enable frogejorunnerservice.service
systemctl start frogejorunnerservice.service
permissions: '0755'
- path: /etc/systemd/system/init-script.service
content: |
[Unit]
Description=One-shot service for initializing Init Script
After=network.target
[Service]
User=root
Type=oneshot
ExecStart=/usr/local/bin/init.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
permissions: '0644'
runcmd:
- systemctl enable --now qemu-guest-agent
- systemctl enable --now init-script.service

Event Timeline

cichy1173 created this object in space S5 Publiczna.
cichy1173 created this object with visibility "Public (No Login Required)".
cichy1173 created this object with edit policy "cichy1173 (Grzegorz Cichocki)".