Deploy Woodpecker CI on Docker with Forgejo for HomeLab CI/CD

HomeLab tutorial - IT technology blog
HomeLab tutorial - IT technology blog

The Real-World Problem: Manual Deployments Break Down Fast

Every HomeLab starts the same way. You fix a bug in a small Python API or a Node.js dashboard, push to your self-hosted Git server, SSH into your Docker host, run git pull, and rebuild the container by hand. With two or three services, that takes thirty seconds. Once you pass ten internal apps, manual deployments turn into a tax on every single change.

Skipping automated checks bit me more than once. I pushed untested code straight to my LAN services, forgot to pass new environment variables during a rebuild, and left half-built containers behind after rushed updates. A lightweight CI/CD pipeline fixes that by testing, building, and deploying every push automatically.

Root Cause Analysis: Why Self-Hosted Automation Gets Skipped

Most engineers already know CI/CD saves time. Still, plenty of HomeLabs skip it. After helping friends set up their home servers and debugging my own early attempts, three blockers kept showing up:

  • Resource bloat: Traditional CI platforms eat 2 GB to 6 GB of RAM just sitting idle. On an Intel N100 mini-PC with 16 GB of memory shared across a dozen services, that overhead is hard to justify.
  • LAN isolation: Cloud runners like GitHub Actions cannot reach your private Docker registry or internal LAN hosts. Working around that means opening firewall ports, maintaining reverse proxies, or wiring up VPN tunnels.
  • Messy runner permissions: Passing the host Docker socket to heavy, long-lived runners often leaves behind root-owned files and 15 GB to 20 GB of stale build cache on your SSD.

You do not need an enterprise platform to solve this. You just need tools that stay small, run inside your LAN, and talk cleanly to your Git server.

Solutions Compared: Picking the Right HomeLab CI/CD Stack

Before settling on a stack, I tested four common setups for self-hosted Git and CI/CD:

  • GitHub Actions (Cloud): Zero server upkeep, yet awkward for internal HomeLab deployments unless you host local runners or expose private endpoints.
  • Jenkins or GitLab CE: Feature-rich and battle-tested, though far too heavy on RAM and maintenance for a single HomeLab node.
  • Forgejo Actions: Built directly into Forgejo and familiar if you already write GitHub workflows. However, runner setup and cache handling feel heavier than necessary for simple container builds.
  • Forgejo + Woodpecker CI on Docker: Forgejo runs comfortably on 100 MB to 150 MB of RAM, while Woodpecker CI idles at roughly 30 MB to 50 MB across its server and agent containers.

Pairing Forgejo with Woodpecker CI works remarkably well for a HomeLab. Each pipeline step runs in an isolated container, configuration lives in one .woodpecker.yml file, and Forgejo OAuth works out of the box.

The Best Approach: Woodpecker CI and Forgejo on Docker

Below is the exact Docker Compose setup I run on my own LAN. It keeps the web UI isolated from the Docker socket and takes less than ten minutes to bring online.

1. Create an OAuth2 Application in Forgejo

Woodpecker delegates user logins and repository webhooks directly to Forgejo. Before starting the containers, log into Forgejo and register an OAuth2 app:

  1. Open Settings → Applications in your Forgejo profile.
  2. Under Manage OAuth2 Applications, enter an application name such as Woodpecker CI.
  3. Set the Redirect URI to match your Woodpecker URL, such as http://woodpecker.lan:8000/authorize or your HTTPS reverse-proxy domain.
  4. Click Create Application and copy both the Client ID and Client Secret.

Tip from experience: Always use a local DNS name or reverse-proxy hostname instead of localhost for the redirect URI. Otherwise, OAuth callbacks will fail whenever you open the dashboard from another machine on your network.

2. Deploy Woodpecker Server and Agent with Docker Compose

Woodpecker splits into two services: woodpecker-server (web UI, API, and Forgejo integration) and woodpecker-agent (the worker that runs pipeline containers). Separating them keeps your web-facing container away from the Docker socket.

Start by generating a 32-byte shared secret so the server and agent can authenticate over gRPC:

openssl rand -hex 32

Next, create a docker-compose.yml file with both services:

services:
  woodpecker-server:
    image: woodpeckerci/woodpecker-server:v2.8
    container_name: woodpecker-server
    restart: unless-stopped
    ports:
      - "8000:8000"
    volumes:
      - woodpecker-server-data:/var/lib/woodpecker/
    environment:
      - WOODPECKER_OPEN=false
      - WOODPECKER_ADMIN=your_forgejo_username
      - WOODPECKER_HOST=http://woodpecker.lan:8000
      - WOODPECKER_FORGEJO=true
      - WOODPECKER_FORGEJO_URL=http://forgejo.lan:3000
      - WOODPECKER_FORGEJO_CLIENT=your_oauth_client_id
      - WOODPECKER_FORGEJO_SECRET=your_oauth_client_secret
      - WOODPECKER_AGENT_SECRET=your_generated_hex_secret

  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:v2.8
    container_name: woodpecker-agent
    restart: unless-stopped
    depends_on:
      - woodpecker-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - WOODPECKER_SERVER=woodpecker-server:9000
      - WOODPECKER_AGENT_SECRET=your_generated_hex_secret
      - WOODPECKER_MAX_WORKFLOWS=2

volumes:
  woodpecker-server-data:

Bring the stack up and watch the logs to confirm the agent connects to port 9000:

docker compose up -d
docker compose logs -f woodpecker-server woodpecker-agent

Two settings here protect a small host right away. Setting WOODPECKER_OPEN=false blocks unwanted sign-ups if you ever expose the UI over a VPN, while WOODPECKER_MAX_WORKFLOWS=2 keeps parallel builds from pegging your CPU.

3. Write a Test, Build, and Deploy Pipeline

Log into Woodpecker with your Forgejo account and activate your target repository. Then add a .woodpecker.yml file at the root of that repo. This example tests a Python service with pytest, tags an image with the short commit SHA, and updates the live container:

when:
  - event: push
    branch: main
  - event: pull_request

steps:
  - name: test
    image: python:3.12-slim
    commands:
      - pip install --no-cache-dir -r requirements.txt
      - pytest -v

  - name: build
    image: docker:27-cli
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    commands:
      - SHORT_SHA=$(echo "$CI_COMMIT_SHA" | cut -c1-7)
      - docker build -t internal-app:$SHORT_SHA -t internal-app:latest .
    when:
      - event: push
        branch: main

  - name: deploy
    image: docker:27-cli
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    commands:
      - docker compose -p internal-app up -d --remove-orphans
    when:
      - event: push
        branch: main

Pull requests run only the test step. Pushes or merges to main continue on to build and deploy. If a test fails, the pipeline halts immediately and your running app stays untouched.

4. Best Practices to Keep Your HomeLab CI/CD Healthy

  • Pin your Woodpecker tags: Avoid :latest for woodpecker-server and woodpecker-agent. Keep both on the same minor version (such as v2.8) so server-to-agent gRPC protocols stay in sync.
  • Store credentials in Woodpecker Secrets: Never hardcode SSH keys, registry tokens, or API passwords in .woodpecker.yml. Add them under your repository’s Secrets tab and inject them with from_secret.
  • Schedule weekly cache pruning: Frequent builds leave dangling layers behind. Add a cron job on your Docker host to clear build cache older than seven days without touching running containers:
0 3 * * 0 docker builder prune -af --filter "until=168h" > /dev/null 2>&1
  • Use Forgejo’s container registry when you add nodes: If you deploy across multiple HomeLab hosts, push built images to Forgejo Packages instead of building on each target machine. Then trigger a quick SSH or webhook pull wherever the container runs.

Once Forgejo and Woodpecker are wired together, pushing a commit handles the entire release cycle. Tests run in clean containers, image tags match exact commits, and your internal apps stop breaking during routine updates.

Share: