Homelab Sample
A generic, opinionated template for setting up a homelab with Terraform, Docker Compose, and monitoring. Everything codified from day one.
A generic, opinionated template for setting up a homelab with Terraform, Docker Compose, and monitoring. Everything codified from day one.
Homelab Sample
A starter template for anyone building a homelab who wants to do it right from the start. Infrastructure as code, monitoring baked in, and sensible defaults for common self-hosted services.
The Problem
After rebuilding my own homelab multiple times, I kept solving the same problems. Directory structure, monitoring setup, Terraform modules, Docker Compose patterns. all reinvented from scratch each time. This template captures the patterns that survived.
Architecture
graph TB
subgraph IaC["Infrastructure as Code"]
TF[Terraform]
TFMOD[Terraform Modules]
STATE[State Backend<br/>Local or S3]
end
subgraph Services["Service Layer"]
DC[Docker Compose]
PROXY[Traefik<br/>Reverse Proxy]
DNS[Cloudflare DNS<br/>via Terraform]
end
subgraph Apps["Application Stack"]
APP1[Service Template A]
APP2[Service Template B]
APP3[Service Template C]
DB[(Database Template)]
end
subgraph Monitor["Monitoring Stack"]
PROM[Prometheus]
GRAF[Grafana]
ALERT[Alertmanager]
NODE[Node Exporter]
CADV[cAdvisor]
end
TF --> TFMOD
TFMOD --> STATE
TF --> DNS
TF --> DC
DC --> PROXY
PROXY --> APP1
PROXY --> APP2
PROXY --> APP3
APP1 --> DB
NODE --> PROM
CADV --> PROM
PROM --> GRAF
PROM --> ALERT
What’s Included
- Terraform for provisioning and managing infrastructure state. DNS records, tunnel configs, and service definitions
- Docker Compose templates for common services (reverse proxy, monitoring, databases)
- Monitoring stack. Prometheus, Grafana, and alerting pre-configured with sensible dashboards
- Opinionated structure. directory layout, naming conventions, and patterns that scale from 5 containers to 50
- cAdvisor + Node Exporter. container and host metrics out of the box
Why a Template
The next homelab build starts at 80% instead of zero. Fork the repo, fill in your variables, and you’ve got a fully monitored, infrastructure-as-code homelab in an afternoon.
Related Posts
- Why I Self-Host Everything. The philosophy behind running your own infrastructure at home and a tour of my homelab setup.
- Using Terraform to Manage Your Home Network. How I use infrastructure as code to manage Cloudflare tunnels, UniFi networking, and DNS.