Problem: Forgejo runner base image is Alpine Linux, not Debian.
- apt-get doesn't exist on Alpine (uses apk instead)
- Runner user (1000) can't modify apk database (Permission denied error)
- Workflow used GitHub-specific conditionals (contains() not Forgejo-compatible)
Solution:
1. Replace apt-get with apk add --no-cache for all runner Dockerfiles
2. Switch to USER root before package installation (apk needs root)
3. Switch back to USER 1000:1000 after install (security)
4. Simplify workflow: build all runners in loop (no conditionals)
Dockerfile changes:
- golang: +nodejs +npm +docker-cli via apk
- node: +nodejs +npm +docker-cli via apk
- rust: +nodejs +npm +curl +docker-cli via apk
Workflow trigger:
- Runs on any Dockerfile.* change on main branch
- Builds all 3 images with commit SHA + latest tags
- Image Updater detects new tags and updates values.yaml
After merge to main:
1. CI builds images: forgejo-runner-{golang,node,rust}:SHA
2. Images pushed to registry
3. Image Updater syncs images and commits values.yaml update
4. ArgoCD deploys new runner pods with docker available
50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
name: Build and push runner images
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.golang'
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.rust'
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.node'
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-runners:
|
|
runs-on: golang
|
|
env:
|
|
REGISTRY: forgejo.riotpiao.com
|
|
IMAGE_BASE: forgejo.riotpiao.com/rock
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get short SHA
|
|
id: sha
|
|
run: |
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Registry login
|
|
run: |
|
|
echo "${REGISTRY_TOKEN}" | docker login "${REGISTRY}" \
|
|
--username "${REGISTRY_USER}" --password-stdin
|
|
env:
|
|
REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }}
|
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push all runner images
|
|
run: |
|
|
set -e
|
|
for RUNNER in golang rust node; do
|
|
echo "📦 Building ${RUNNER}-runner..."
|
|
docker build -f "k8s/infra/forgejo-runner/Dockerfile.${RUNNER}" \
|
|
-t "${IMAGE_BASE}/forgejo-runner-${RUNNER}:${{ steps.sha.outputs.short_sha }}" \
|
|
-t "${IMAGE_BASE}/forgejo-runner-${RUNNER}:latest" \
|
|
.
|
|
docker push "${IMAGE_BASE}/forgejo-runner-${RUNNER}:${{ steps.sha.outputs.short_sha }}"
|
|
docker push "${IMAGE_BASE}/forgejo-runner-${RUNNER}:latest"
|
|
echo "✅ Pushed ${RUNNER}-runner"
|
|
done
|
|
echo "\n✅ All runner images built and pushed"
|