Home Server › Containers

Self-hosting Gitea CI/CD with a rootless Docker Actions runner

Deploy lightweight self-hosted Git and CI/CD with Gitea, Authelia OIDC login enforcement, and a rootless Docker-in-Docker Actions runner.

Self-hosting Gitea CI/CD with a rootless Docker Actions runner

GitLab is overkill for a single-node homelab when it eats 4–8 GB of RAM just sitting idle. Here is how I deployed Gitea in under 100 MB of memory, locked sign-ins exclusively to Authelia OIDC, and isolated CI builds inside a rootless Docker-in-Docker Actions runner.

Tested with Gitea (gitea/gitea:latest), Gitea Act Runner (gitea/runner:5-dind-rootless), PostgreSQL, and Authelia OIDC on Docker Compose.


Why self-host Git and CI/CD in a homelab

GitHub handles public repositories and open-source collaboration well, so I don’t try to replace it for everything. Still, there are three cases where a local Git server pays off quickly:

  • Keeping homelab Compose stacks, private configs, and internal scripts on your own network rather than a third-party host.
  • Pushing and pulling large repositories or container images at gigabit LAN speed without external bandwidth caps.
  • Running unlimited CI/CD minutes for personal builds without hitting GitHub Actions free-tier quotas.

Gitea is written in Go, idles under 100 MB of RAM, and ships with Gitea Actions, which reuses GitHub Actions workflow syntax (.gitea/workflows/). That means most actions/checkout and build steps transfer over with minimal changes.

OptionIdle RAMCI/CD modelBest fit
Gitea + Act Runner~100 MBGitHub Actions-compatible workflowsLow-power homelabs, personal private repos, Docker builds
GitLab CE4–8 GB+Full DevSecOps suite, native runnersTeams needing integrated epics, security scanners, and enterprise RBAC
GitHub Free/Pro0 MB localManaged runners (minute limits on private repos)Public repos, open-source PRs, zero local maintenance

When not to self-host: If you need external contributors to open pull requests, rely on GitHub Marketplace apps, or don’t have automated off-box backups for your PostgreSQL database and Git volumes, keep those repositories on GitHub.


Security architecture and rootless runner isolation

The fastest way to break host isolation in a self-hosted CI pipeline is mounting /var/run/docker.sock directly into the runner container or running a standard rootful docker:dind daemon. If a compromised dependency or workflow step runs a malicious container command against the host socket, it effectively owns root on the host machine.

To keep build jobs contained, I paired two controls in this stack:

  1. OIDC-only authentication: Gitea’s local password form, passkeys, and self-registration are disabled (ENABLE_PASSWORD_SIGNIN_FORM: "false"). Every user must authenticate through Authelia SSO.
  2. Rootless DinD sandbox: The gitea/runner:5-dind-rootless image runs its inner dockerd inside a user namespace under an unprivileged UID (1000) using slirp4netns for networking. Build containers live inside that sandboxed daemon rather than the host’s Docker engine.
flowchart TD
    subgraph Ingress["Web and SSH ingress"]
        Dev["Developer"] -->|"HTTPS (git.namju.kim)"| NPM["Nginx Proxy Manager"]
        Dev -->|"SSH (port 2222)"| Gitea
    end

    subgraph DevStack["Development stack (Docker Compose)"]
        NPM --> Gitea["Gitea Server<br/>(port 3000)"]
        subgraph RunnerBox["Isolated CI runner: gitea-runner"]
            Runner["Gitea Act Runner"]
            Rootless["Rootless dockerd<br/>(UID 1000 / slirp4netns)"]
            Runner --- Rootless
        end
    end

    subgraph AuthData["Auth and persistence"]
        Gitea -->|"OIDC token check"| Auth["Authelia (SSO)"]
        Gitea -->|"Data storage"| PG["PostgreSQL"]
    end

    Gitea -->|"Poll job queue (gRPC)"| Runner

Docker Compose setup for Gitea and the runner

Here is the full development/docker-compose.yaml. Notice how Gitea binds SSH on port 2222 (avoiding a conflict with the host’s port 22) and connects to the shared database_network where PostgreSQL runs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# development/docker-compose.yaml
name: development

services:
  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    restart: unless-stopped
    environment:
      TZ: Asia/Seoul

      # PostgreSQL connection
      GITEA__database__DB_TYPE: postgres
      GITEA__database__HOST: postgres:5432
      GITEA__database__NAME: gitea
      GITEA__database__USER: gitea_user
      GITEA__database__PASSWD: ${GITEA_DB_PASSWORD:?required}
      GITEA__database__SSL_MODE: disable

      # Server and public URL settings
      GITEA__server__DOMAIN: git.namju.kim
      GITEA__server__ROOT_URL: https://git.namju.kim/
      GITEA__server__PROTOCOL: http
      GITEA__server__HTTP_PORT: 3000

      # Git SSH port (2222 to avoid colliding with host sshd on 22)
      GITEA__server__SSH_DOMAIN: git.namju.kim
      GITEA__server__SSH_PORT: 2222
      GITEA__server__SSH_LISTEN_PORT: 2222

      # Registration and sign-in restrictions
      GITEA__service__DISABLE_REGISTRATION: "false"
      GITEA__service__ALLOW_ONLY_EXTERNAL_REGISTRATION: "true"
      GITEA__service__SHOW_REGISTRATION_BUTTON: "false"
      GITEA__service__ENABLE_PASSWORD_SIGNIN_FORM: "false"
      GITEA__service__ENABLE_PASSKEY_AUTHENTICATION: "false"
      GITEA__service__REQUIRE_SIGNIN_VIEW: "true"

      # Automatic account provisioning via OIDC
      GITEA__oauth2_client__ENABLE_AUTO_REGISTRATION: "true"
      GITEA__oauth2_client__USERNAME: preferred_username

      # Enable package registry and Gitea Actions
      GITEA__packages__ENABLED: "true"
      GITEA__actions__ENABLED: "true"

    ports:
      - "${SERVER_IP:?required}:2222:2222"

    volumes:
      - gitea_data:/var/lib/gitea
      - gitea_config:/etc/gitea

    networks:
      - proxy_network
      - database_network
      - monitoring_network

  runner:
    image: gitea/runner:5-dind-rootless
    container_name: gitea-runner
    restart: unless-stopped
    privileged: true
    environment:
      TZ: Asia/Seoul
      GITEA_INSTANCE_URL: https://git.namju.kim
      GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_TOKEN:?required}
      GITEA_RUNNER_NAME: homelab-runner
      GITEA_RUNNER_LABELS: "ubuntu-latest:docker://node:22-bookworm,docker:docker://docker:dind"
      CONFIG_FILE: /config.yaml
      DOCKERD_ROOTLESS_ROOTLESSKIT_NET: slirp4netns
      DOCKERD_ROOTLESS_ROOTLESSKIT_MTU: "65520"
    volumes:
      - runner_data:/data
      - runner_docker:/home/rootless/.local/share/docker
      - ./gitea/config.yaml:/config.yaml:ro
    networks:
      - proxy_network
      - monitoring_network

volumes:
  gitea_data:
  gitea_config:
  runner_data:
  runner_docker:

networks:
  proxy_network:
    external: true
  database_network:
    external: true
  monitoring_network:
    external: true

A few environment variables here do heavy lifting:

  • ALLOW_ONLY_EXTERNAL_REGISTRATION: "true" combined with ENABLE_AUTO_REGISTRATION: "true" lets first-time OIDC users sign in cleanly without creating a manual local account, while blocking anyone from registering via a form.
  • REQUIRE_SIGNIN_VIEW: "true" hides all repositories and user profiles from unauthenticated visitors.
  • DOCKERD_ROOTLESS_ROOTLESSKIT_NET: slirp4netns and MTU: "65520" give the rootless network stack reliable outbound connectivity without needing host root privileges inside the nested daemon.

Connecting Gitea to Authelia OIDC

Once Gitea is up, open the admin console at https://git.namju.kim/admin/auths and add a new OAuth2 authentication source:

  • Authentication Name: Authelia
  • OAuth2 Provider: OpenID Connect
  • Client ID: gitea
  • Client Secret: The plaintext secret matching the PBKDF2 hash registered in Authelia
  • OpenID Connect Auto Discovery URL: https://auth.namju.kim/.well-known/openid-configuration

After saving, visiting https://git.namju.kim hides the username/password fields and shows only the Sign in with Authelia button. Clicking it bounces through Authelia SSO, maps preferred_username from the OIDC token, and provisions the Gitea account automatically on first login.


Registering the Actions runner and verifying a build

With Gitea running and OIDC working, register the runner in three steps:

  1. In Gitea, open Site Administration → Actions → Runners and copy the Registration Token.
  2. Add GITEA_RUNNER_TOKEN=<your-token> to development/.env.
  3. Start the runner container:
1
docker compose up -d runner

Check docker logs gitea-runner to confirm it registers cleanly as homelab-runner and starts polling for jobs.

Smoke-testing the rootless pipeline (.gitea/workflows/build-test.yaml)

Add a minimal workflow to a test repository to verify that jobs execute inside the rootless Docker daemon:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
name: Rootless Docker Build Test

on: [push]

jobs:
  test-build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4

      - name: Check User and Environment
        run: |
          whoami
          docker version
          id

Push the commit and open the Actions tab in Gitea. The job should pick up ubuntu-latest, run the container steps inside gitea-runner’s nested dockerd, and finish green without ever touching the host Docker socket.


Production caveats and checklist

Why privileged: true is still set on the runner: RootlessKit inside Docker requires user-namespace creation and mount capabilities that standard unprivileged containers block by default. Even with privileged: true on the outer runner container, the inner dockerd drops to UID 1000 inside a separate user namespace—far safer than mounting /var/run/docker.sock, though you should still avoid running untrusted public pull requests on a homelab runner.

First admin account bootstrap: If you set ENABLE_PASSWORD_SIGNIN_FORM: "false" before creating your initial admin user, you can lock yourself out of /admin/auths. Either keep password login enabled just long enough to register the Authelia OIDC provider, or promote your first OIDC user via docker exec -u git gitea gitea admin user change-password / gitea admin user must-change-password.

Before calling your CI/CD setup complete, verify:

  • gitea_data and the gitea PostgreSQL database are included in your backup schedule.
  • Port 2222 is bound to ${SERVER_IP} (not exposed accidentally if you only want LAN/VPN Git SSH access).
  • runner_docker volume disk usage is monitored or pruned periodically—nested Docker build caches grow quickly over time.
  • Unauthenticated requests to https://git.namju.kim redirect to sign-in (REQUIRE_SIGNIN_VIEW: "true").
This post is licensed under CC BY 4.0 by the author.