I wanted to deploy a few basic services that would make my life a little easier when working with my homelab. These include a cache for Docker images, a place to host Git repositories, and somewhere to store and manage secrets.

I already had a Raspberry Pi 4 with 4 cores and 8GB of RAM available, which seemed more than capable of handling these workloads. For storage, I wanted to avoid using an SD card due to its reliability issues, so I used an external Samsung T7 1TB SSD instead.

For the operating system, I went with Alpine Linux, which worked out great. After getting the system up and running, I kept things simple and installed only Docker and Docker Compose.

The goal is to run all services as containers, making the setup easy to maintain and portable. Below we will see how to deploy and configure these services using Docker Compose.


HAProxy

All services run behind an HAProxy instance, which acts as a reverse proxy that routes traffic to the appropriate backend service and handles TLS termination.

HAProxy listens on ports 80 and 443 on the host. It also listens on one more port on the host for Forgejo’s SSH service. We could use port 22 for this if the host’s SSH server is configured to listen on a different port.


Zot

We deploy Zot as a virtual registry that mirrors the following upstream registries..

  • quay.io
  • registry.k8s.io
  • codeberg.org
  • ghcr.io
  • docker.io

Zot fetches and caches images from the configured upstream registries on demand, serving future image pulls directly from its local cache. This makes image pulls faster, reduces traffic to upstream registries, and helps avoid rate limits.

Assuming our domain name is example.com we can use the virtual registry in the following ways..

  • pull a specific image tag or digest..

    docker pull registry.example.com/alpine:3.24.4
    docker pull registry.example.com/alpine@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
    
  • use it in Docker Compose files..

    # set VIRTUAL_REGISTRY="registry.example.com" in the compose .env file
    services:
      alpine:
        image: ${VIRTUAL_REGISTRY:-docker.io}/alpine:3.24.4
        command: ["sleep", "infinity"]
    
  • use it in supported Helm charts..

    global:
      imageRegistry: registry.example.com
    
  • use it in K8s with Kyverno to enforce the use of the virtual registry when pods are created

Zot must be accessible over HTTPS with a valid TLS certificate, this is handled in our case by HAProxy. A web UI is available at https://registry.${DOMAIN_NAME}, where we can browse our cached images and view useful information about them.

Note

Docker may time out when pulling images for the first time through the virtual registry. If this happens, give the registry a couple of minutes to complete the downloads before retrying.


Forgejo

We use Forgejo to host and manage Git repositories. Our installation is very opinionated, with most unnecessary features disabled through environment variables. For its database, we use SQLite as it is more than sufficient for our needs. The SSH port we configure determines the port included in the SSH clone URLs provided by Forgejo.

After deploying Forgejo, we can create users using the following command..

USERNAME=""

docker compose exec -u git forgejo \
  forgejo admin user create \
  --admin \
  --must-change-password \
  --username "${USERNAME}" \
  --email "${USERNAME}@forgejo.internal" \
  --password 'c7D94STZD5QSEMwZ'

The web UI is available at https://git.${DOMAIN_NAME}, we log in using the credentials of the user we created. On the first login we will be prompted to change our password.

For more information about Forgejo’s available environment variables and their options, check its sample configuration file.

If the plan is to use Git repositories hosted on Forgejo with Argo CD, we need to add Forgejo’s SSH host keys to Argo CD’s trusted hosts. To do this, we run the following command and add its output under configs.ssh.extraHosts in the Argo CD values file..

DOMAIN_NAME=""
FORGEJO_SSH_PORT=""

ssh-keyscan -p "${FORGEJO_SSH_PORT}" git.${DOMAIN_NAME} | sed '/^#/d'

OpenBao

We use OpenBao to store, manage, and distribute secrets. By default after a restart, OpenBao is sealed and requires an unseal key to become operational. For simplicity we use auto-unseal with the required key passed to OpenBao through an environment variable.

To generate the auto-unseal key we run..

openssl rand -hex 32

After deployment, OpenBao must be manually initialized to generate the initial root token and recovery keys. Again for simplicity we configure a single recovery key with a threshold of one..

docker compose exec openbao bao operator init -recovery-shares=1 -recovery-threshold=1

Warning

This is a simplified OpenBao deployment that should not be considered production ready.

The web UI is available at https://vault.${DOMAIN_NAME}. Log in using the root token that was created during initialization.


Initial Setup

To deploy the services we do the following..

  1. Decide which domain or subdomain to use for the deployment (we will use the subdomain dev.example.com throughout the remaining steps).
  2. Configure DNS records for both dev.example.com and *.dev.example.com and point them to the IP address of the machine that will host the services.
  3. Make sure the TLS certificate covers both dev.example.com and *.dev.example.com.
  4. Download the .env and compose.yaml files on the machine that will host the services.
  5. Fill in the missing values in the .env file.
  6. Start the services with docker compose up -d.
  7. Create the initial Forgejo user.
  8. Initialize OpenBao and generate its root token and recovery keys.
Show .env file
ARCHITECTURE=""         # arm64
DOMAIN_NAME=""          # dev.example.com
IP_ADDRESS=""           # 192.168.1.10
TLS_CERTIFICATE_PATH="" # $HOME/.tls/tls.pem
FORGEJO_SSH_PORT=""     # 2222
BAO_SEAL_KEY=""         # fbc739c7fa4cc08a11b20bcbaebb02e0354f7959dda9d8e65d6adc041f4a0b3f
Show compose.yaml file
name: backend

networks:
  backend:
    driver: bridge

volumes:
  forgejo: {}
  openbao: {}
  zot: {}

services:
  forgejo:
    environment:
      FORGEJO____APP_NAME: "Forgejo"
      FORGEJO__server__DOMAIN: "git.${DOMAIN_NAME:?}"
      FORGEJO__server__ROOT_URL: "https://git.${DOMAIN_NAME:?}/"
      FORGEJO__server__SSH_DOMAIN: "git.${DOMAIN_NAME:?}"
      FORGEJO__server__SSH_PORT: "${FORGEJO_SSH_PORT:?}"
      FORGEJO__server__OFFLINE_MODE: "true"
      FORGEJO__server__LANDING_PAGE: "login"
      FORGEJO__security__INSTALL_LOCK: "true"
      FORGEJO__service__DISABLE_REGISTRATION: "true"
      FORGEJO__service__REQUIRE_SIGNIN_VIEW: "true"
      FORGEJO__service__DEFAULT_KEEP_EMAIL_PRIVATE: "true"
      FORGEJO__service__DEFAULT_ALLOW_CREATE_ORGANIZATION: "false"
      FORGEJO__service__DEFAULT_USER_VISIBILITY: "private"
      FORGEJO__service__DEFAULT_ORG_VISIBILITY: "private"
      FORGEJO__service__ENABLE_USER_HEATMAP: "false"
      FORGEJO__service__ENABLE_TIMETRACKING: "false"
      FORGEJO__service__SHOW_MILESTONES_DASHBOARD_PAGE: "false"
      FORGEJO__service__AUTO_WATCH_NEW_REPOS: "false"
      FORGEJO__service.explore__DISABLE_USERS_PAGE: "true"
      FORGEJO__service.explore__DISABLE_ORGANIZATIONS_PAGE: "true"
      FORGEJO__repository__FORCE_PRIVATE: "true"
      FORGEJO__repository__DEFAULT_PRIVATE: "private"
      FORGEJO__repository__DISABLED_REPO_UNITS: "repo.issues,repo.ext_issues,repo.wiki,repo.ext_wiki,repo.projects"
      FORGEJO__repository__DISABLE_MIGRATIONS: "true"
      FORGEJO__repository__DISABLE_STARS: "true"
      FORGEJO__repository__DISABLE_FORKS: "true"
      FORGEJO__repository__DEFAULT_BRANCH: "master"
      FORGEJO__ui__SHOW_USER_EMAIL: "false"
      FORGEJO__picture__DISABLE_GRAVATAR: "true"
      FORGEJO__other__SHOW_FOOTER_VERSION: "false"
      FORGEJO__other__SHOW_FOOTER_TEMPLATE_LOAD_TIME: "false"
      FORGEJO__other__SHOW_FOOTER_POWERED_BY: "false"
      FORGEJO__other__ENABLE_SITEMAP: "false"
      FORGEJO__other__ENABLE_FEED: "false"
      FORGEJO__metrics__ENABLED: "true"
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3000/api/healthz"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s
      start_interval: 5s
    image: codeberg.org/forgejo/forgejo:17.0.1
    networks:
      - backend
    restart: unless-stopped
    volumes:
      - forgejo:/data

  haproxy:
    configs:
      - source: haproxy-01
        target: /usr/local/etc/haproxy/haproxy.cfg
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8404"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s
      start_interval: 5s
    image: docker.io/haproxytech/haproxy-alpine:3.4
    networks:
      - backend
    ports:
      - ${IP_ADDRESS:?}:${FORGEJO_SSH_PORT:?}:${FORGEJO_SSH_PORT:?}
      - ${IP_ADDRESS:?}:80:80
      - ${IP_ADDRESS:?}:443:443
    restart: unless-stopped
    volumes:
      - ${TLS_CERTIFICATE_PATH:?}:/usr/local/etc/haproxy/tls/haproxy.pem:ro

  openbao:
    command:
      - 'server'
    configs:
      - source: openbao-01
        target: /openbao/config/config.hcl
    environment:
      BAO_ADDR: "http://127.0.0.1:8200"
      BAO_SEAL_KEY: "${BAO_SEAL_KEY:?}"
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8200/v1/sys/health?standbyok=true&sealedcode=204&uninitcode=204"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s
      start_interval: 5s
    image: docker.io/openbao/openbao:2.7.2
    networks:
      - backend
    restart: unless-stopped
    volumes:
      - openbao:/openbao/file

  zot:
    command:
      - 'serve'
      - '/etc/zot/config.json'
    configs:
      - source: zot-01
        target: /etc/zot/config.json
    healthcheck:
      test: ["CMD", "/usr/local/bin/zot-linux-${ARCHITECTURE:?}", "healthcheck", "--insecure-skip-verify", "/etc/zot/config.json"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s
      start_interval: 5s
    image: ghcr.io/project-zot/zot:v2.1.23
    networks:
      - backend
    restart: unless-stopped
    volumes:
      - zot:/var/lib/registry

configs:
  haproxy-01:
    content: |
      global
        user haproxy
        group haproxy
        stats socket /var/run/api.sock user haproxy group haproxy mode 660 level admin expose-fd listeners
        log stdout format raw local0 info

      defaults
        log global
        maxconn 2000
        timeout connect 2s
        timeout client 30s
        timeout server 30s
        timeout tunnel 1h
        timeout http-keep-alive 5s
        timeout http-request 10s
        timeout queue 10s
        timeout check 5s

      resolvers docker
        nameserver dns1 127.0.0.11:53
        resolve_retries 3
        timeout resolve 1s
        timeout retry 1s
        hold valid 10s
        hold obsolete 30s
        hold other 10s

      frontend haproxy-stats
        mode http
        bind *:8404
        stats enable
        stats uri /
        stats refresh 5m
        no log

      frontend docker-frontend-ssh
        mode tcp
        bind *:${FORGEJO_SSH_PORT:?}

        default_backend docker-backend-ssh

      frontend docker-frontend-http
        mode http
        bind *:80
        bind *:443 ssl crt /usr/local/etc/haproxy/tls/

        option httplog
        http-request redirect scheme https unless { ssl_fc }

        option forwardfor
        http-request set-header X-Real-IP %[src]
        http-request set-header X-Forwarded-Proto https if { ssl_fc }

        compression algo gzip
        compression type text/html text/plain text/css application/javascript

        default_backend docker-backend-default

        acl host_git hdr(host) -i git.${DOMAIN_NAME:?}
        acl host_registry hdr(host) -i registry.${DOMAIN_NAME:?}
        acl host_vault hdr(host) -i vault.${DOMAIN_NAME:?}

        use_backend docker-backend-git if host_git
        use_backend docker-backend-registry if host_registry
        use_backend docker-backend-vault if host_vault

      backend docker-backend-ssh
        mode tcp
        server s1 forgejo:22 check resolvers docker init-addr none

      backend docker-backend-git
        mode http
        server s1 forgejo:3000 check resolvers docker init-addr none

      backend docker-backend-registry
        mode http
        server s1 zot:5000 check resolvers docker init-addr none

      backend docker-backend-vault
        mode http
        server s1 openbao:8200 check resolvers docker init-addr none

      backend docker-backend-default
        mode http
        http-request return status 404 content-type "text/html" string "<h1>404 Not Found</h1>"

  openbao-01:
    content: |
      ui            = true
      disable_mlock = true

      api_addr     = "https://vault.${DOMAIN_NAME:?}"
      cluster_addr = "https://openbao-01.openbao.internal:8201"

      telemetry {
        disable_hostname          = true
        enable_hostname_label     = true
        prometheus_retention_time = "24h"
      }

      storage "raft" {
        path    = "/openbao/file"
        node_id = "openbao-01"
      }

      seal "static" {
        current_key_id = "20261102-1"
        current_key    = "env://BAO_SEAL_KEY"
      }

      listener "tcp" {
        address         = "0.0.0.0:8200"
        cluster_address = "0.0.0.0:8201"
        tls_disable     = true
      }

      listener "tcp" {
        address     = "0.0.0.0:8202"
        tls_disable = true

        telemetry {
          unauthenticated_metrics_access = true
          metrics_only                   = true
          metrics_path                   = "/metrics"
        }
      }

  zot-01:
    content: |
      {
        "distSpecVersion": "1.1.1",
        "storage": {
          "rootDirectory": "/var/lib/registry"
        },
        "http": {
          "address": "0.0.0.0",
          "port": 5000,
          "compat": ["docker2s2"]
        },
        "log": {
          "level": "info"
        },
        "extensions": {
          "lint": {
            "enable": false
          },
          "metrics": {
            "enable": true,
            "prometheus": {
              "path": "/metrics"
            }
          },
          "scrub": {
            "enable": true,
            "interval": "24h"
          },
          "search": {
            "enable": true,
            "cve": {
              "updateInterval": "2h"
            }
          },
          "sync": {
            "enable": true,
            "registries": [
              {
                "urls": ["https://quay.io"],
                "onDemand": true,
                "manifestCheckInterval": "0s",
                "tlsVerify": true,
                "maxRetries": 3,
                "retryDelay": "10s",
                "syncTimeout": "3h",
                "content": [
                  {
                    "prefix": "**"
                  }
                ]
              },
              {
                "urls": ["https://registry.k8s.io"],
                "onDemand": true,
                "manifestCheckInterval": "0s",
                "tlsVerify": true,
                "maxRetries": 3,
                "retryDelay": "10s",
                "syncTimeout": "3h",
                "content": [
                  {
                    "prefix": "**"
                  }
                ]
              },
              {
                "urls": ["https://codeberg.org"],
                "onDemand": true,
                "manifestCheckInterval": "0s",
                "tlsVerify": true,
                "maxRetries": 3,
                "retryDelay": "10s",
                "syncTimeout": "3h",
                "content": [
                  {
                    "prefix": "**"
                  }
                ]
              },
              {
                "urls": ["https://ghcr.io"],
                "onDemand": true,
                "manifestCheckInterval": "0s",
                "tlsVerify": true,
                "maxRetries": 3,
                "retryDelay": "10s",
                "syncTimeout": "3h",
                "content": [
                  {
                    "prefix": "**"
                  }
                ]
              },
              {
                "urls": ["https://registry-1.docker.io"],
                "onDemand": true,
                "manifestCheckInterval": "0s",
                "tlsVerify": true,
                "maxRetries": 3,
                "retryDelay": "10s",
                "syncTimeout": "3h",
                "content": [
                  {
                    "prefix": "**"
                  }
                ]
              }
            ]
          },
          "trust": {
            "enable": false
          },
          "ui": {
            "enable": true
          }
        }
      }

Ongoing Maintenance

Just a few things to keep in mind to keep everything happy. Renew the TLS certificate before it expires, update the container image tags when new versions are available, and make regular backups of the data stored in the Docker volumes.