A Bauhaus assembly-line composition on a warm cream canvas. On the left, a black cube labelled 'git push' feeds into a row of three amber conveyor belts that process it through cream stations labelled 'build', 'test', 'deploy'. A red arrow delivers the finished output to a small cream website icon on the right. Bauhaus punctuation dots, grounding triangle.
[ AI & Automation ]7 min read

Automating the Boring Stuff: A Homelab Software Factory

Phase 4 · Autonomous Agents and UX

Self-hosted Git, a CI runner that actually runs on my hardware, and the fourteen-second path from 'git push' to a live site.

GiteaWoodpecker CIDockerrsync

The mechanical step between “I changed a line of code” and “the live site serves that change” should not exist in a professional workflow, and yet for most of my career it did. I would ship a commit, SSH to a server, pull the repository, run a build command, copy files around, and hope nothing went wrong between my laptop and the public URL. The process was ten minutes each time, and the ten minutes included a recurring small fear: what if I type the wrong thing and break the site.

The industry solved this problem twenty years ago. A CI/CD pipeline is a boring automaton that watches a repository, runs a script when a commit lands on the right branch, and moves the built artefacts to the right server. The pipeline never mistypes. The pipeline never skips a step. The pipeline leaves a log of every decision, and if a step fails, the pipeline is the thing that shouts, not the site. I had been the pipeline for years because I had outsourced the repository layer to a commercial host (GitHub) and because setting up the rest looked intimidating. It is not. The self-hosted version fits in two containers on a modest VM and took less time to stand up than the first draft of this entry.

The Analogy

Before standardised manufacturing, every watch was assembled by a master watchmaker who did every step: mill the gears, stamp the case, polish the glass, deliver to the store. The watch was fine. The throughput was one watch per watchmaker per week, and the watchmaker was exhausted.

Standardised manufacturing decoupled the watchmaker from every step that did not need their eye. Gear-milling is a machine job. Polishing is a machine job. Packaging is a machine job. The watchmaker returns to designing the watch. The assembly line handles the rest.

A homelab software factory does the same split. The designer writes the code. The pipeline handles the repetitive, error-prone, bureaucratic parts of getting the code from a laptop to a public server. The designer’s bandwidth returns to the work that actually needs judgement.

The Tech Translated

Two pieces make up the smallest functional self-hosted software factory:

A self-hosted Git server. Somewhere for the repository to live that is not a commercial cloud. I use Gitea: a single Go binary, tiny memory footprint, web UI that does 90% of what GitHub’s does, supports pull requests, issues, and webhooks out of the box.

A CI runner. Something that watches the repository for commits, executes a declarative pipeline, and reports results. I use Woodpecker CI, which forked from Drone CI in 2019 and now runs as a two-binary system (server + agent). It speaks to Gitea over OAuth, and pipelines are declared in .woodpecker.yml files alongside the code.

Together they cost around 250 MB of disk and 400 MB of RAM idle. They run as a pair of Docker containers on one of my less-busy VMs and serve every private repository in the lab, including this site.

# docker-compose.yml — Gitea + Woodpecker on one VM.
services:
  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    restart: unless-stopped
    environment:
      USER_UID: 1000
      USER_GID: 1000
      GITEA__database__DB_TYPE: sqlite3
    volumes:
      - ./gitea-data:/data
    ports:
      - "198.51.100.30:3000:3000"   # Web UI
      - "198.51.100.30:2222:22"     # SSH for git remotes

  woodpecker-server:
    image: woodpeckerci/woodpecker-server:latest
    container_name: woodpecker-server
    restart: unless-stopped
    environment:
      WOODPECKER_OPEN: "true"
      WOODPECKER_HOST: "https://ci.internal"
      WOODPECKER_GITEA: "true"
      WOODPECKER_GITEA_URL: "https://git.internal"
      WOODPECKER_GITEA_CLIENT: "${GITEA_OAUTH_CLIENT_ID}"
      WOODPECKER_GITEA_SECRET: "${GITEA_OAUTH_SECRET}"
      WOODPECKER_AGENT_SECRET: "${WOODPECKER_AGENT_SECRET}"
    volumes:
      - ./woodpecker-data:/var/lib/woodpecker
    ports:
      - "198.51.100.30:8000:8000"

  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:latest
    container_name: woodpecker-agent
    restart: unless-stopped
    depends_on:
      - woodpecker-server
    environment:
      WOODPECKER_SERVER: "woodpecker-server:9000"
      WOODPECKER_AGENT_SECRET: "${WOODPECKER_AGENT_SECRET}"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Bring it up, register Woodpecker as a Gitea OAuth app, accept the first repository in the Woodpecker UI, and the factory is operational.

The Action

A pipeline for this site

The .woodpecker.yml file that ships this portfolio is short, honest, and fits on one screen. Every Astro site deploys the same way at a high level: install, build, ship.

# .woodpecker.yml at the root of the sebastianbourges-com repository.
when:
  - event: push
    branch: main

steps:
  install:
    image: node:20-alpine
    commands:
      - corepack enable
      - pnpm install --frozen-lockfile

  test:
    image: node:20-alpine
    commands:
      - pnpm test
      - pnpm lint:prose:all

  build:
    image: node:20-alpine
    commands:
      - pnpm build

  deploy:
    image: alpine:3.19
    commands:
      - apk add --no-cache openssh-client rsync
      - mkdir -p ~/.ssh && echo "$SSH_HOST_KEY" >> ~/.ssh/known_hosts
      - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
      - chmod 600 ~/.ssh/id_ed25519
      - rsync -azH --delete dist/ deploy@web.internal:/var/www/sebastianbourges.com/
    secrets: [ ssh_host_key, ssh_private_key ]

Commit, git push origin main, and the pipeline handles the rest. The Woodpecker UI shows four green dots. The live site reflects the change in about fourteen seconds end-to-end. I no longer log into the production web server for any reason related to deploying. The last time I SSHed to it was to add a systemd timer for log rotation.

What broke

The fix-point cycle of any pipeline involves a week where every small mistake breaks CI and teaches you one piece of infrastructure. Three bugs from my first two weeks, in increasing order of how sheepish they made me:

  1. The deploy step had no when: event=push, branch=main guard initially. The pipeline deployed on every branch push. The first time I worked on a feature branch, it overwrote production with half-finished content for six minutes. Fix: guard every deploy step with a branch filter.
  2. Secrets were being echoed into build logs. I had echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 running under set -x, and the log proudly displayed the full key. Rotation, cleanup of the git log, and a rule that all credential-handling commands run with explicit { set +x; …; } groups.
  3. The Gitea container’s hostname was gitea, not git.internal. Woodpecker talked to it fine container-to-container, but webhooks from Gitea to Woodpecker went out via the configured external URL, and DNS from inside the Gitea container did not resolve the external name. Fix: add an explicit extra_hosts line to Gitea so it can find the CI server by name, or add a reverse-proxy that handles both.

Each bug was small and survivable, and each one is a permanent note in the .woodpecker.yml template I reuse across new repositories. The factory is now trustworthy because the failure modes are known.

The quiet dividend

I push code more often now. That sentence is small, and the behaviour change behind it is the whole point of the project. When deploying is a chore, you batch changes and ship reluctantly. When deploying is a fourteen-second background job that leaves a log, you ship each change the moment it is ready. The site improves more often. The feedback loop shortens. The quality rises because the tax on iteration fell.

That is the whole pitch for a software factory in a personal lab. The commercial CI services are fine; they just cost money, ask for your source code, and change pricing. The self-hosted version costs a few hundred megabytes and answers only to you. For a portfolio site that ships from the same hardware that runs the rest of the lab, the symmetry is beautiful.

Footnotes

  1. Gitea is MIT-licensed. Home: about.gitea.com. It forked from Gogs in 2016 and is now a CNCF sandbox project. ↩

  2. Woodpecker CI is Apache-2.0-licensed. Home: woodpecker-ci.org. It is the community fork of Drone CI following Drone’s licence change in 2019. ↩

Table of Contents