Skip to content

Repository files navigation

Raspberry Pi Home Lab (Docker)

This repository contains the Docker Compose configuration for a comprehensive home lab setup running on a Raspberry Pi (optimized for Pi 5). It integrates various self-hosted services using a custom bridge network and Tailscale for secure remote access.

🚀 Overview

The stack is designed to be efficient and secure, utilizing Caddy as a reverse proxy with Cloudflare DNS validation for automatic SSL certificates. A specific subnet (10.8.1.0/24) is used to assign static IPs to containers, facilitating easy internal DNS resolution via Pi-hole.

Core Infrastructure

  • Caddy: Reverse proxy handling *.pi.rahulja.in domains.
  • Tailscale: VPN and subnet router for secure remote access.
  • Pi-hole: Network-wide ad blocking and local DNS.
  • DNSCrypt-Proxy: Provides encrypted upstream DNS for Pi-hole.

📐 Architecture

The following diagram illustrates the Unified Network Core architecture. Services like Caddy, Pi-hole, and DNSCrypt-Proxy share the Tailscale network namespace, allowing them to operate as a single logical gateway at 10.8.1.48.

graph TD
%% --- External ---
User((Remote User))
CF_DNS[Cloudflare / Upstream DNS]
subgraph TS_Mesh ["Tailscale Mesh (VPN)"]
TS_Interface["Tailscale Interface<br/>(100.x.y.z)"]
end
%% --- The Server ---
subgraph RPi ["Raspberry Pi 5"]
subgraph Unified_Core ["Unified Network Core (IP: 10.8.1.48)"]
direction TB
TS_Client[Tailscale Container]
Caddy[Caddy Reverse Proxy]
Pihole[Pi-hole DNS]
DNSCrypt[DNSCrypt-Proxy]
%% Internal Core Links
TS_Client <--> Caddy
Caddy <--> Pihole
Pihole ---|localhost#5053| DNSCrypt
end
subgraph Bridge_Net ["wg-easy Bridge (10.8.1.0/24)"]
direction LR
Apps["App Containers<br/>(Immich, n8n, etc.)"]
Storage[("/mnt/usb")]
end
end
%% --- Traffic Flows ---
%% Flow 1: External Access
User ==>|Secure Tunnel| TS_Mesh
TS_Mesh ==> TS_Interface
TS_Interface ==>|Port 80/443| Caddy
Caddy ==>|Reverse Proxy| Apps
%% Flow 2: Internal DNS
Apps -.->|DNS Query| Pihole
Pihole -.->|Upstream| DNSCrypt
DNSCrypt -.->|DoH / DNSCrypt| CF_DNS
%% Flow 3: Storage
Apps --- Storage
%% Styling
style Unified_Core fill:#f0f7ff,stroke:#005cc5,stroke-width:2px
style TS_Client fill:#fff,stroke:#333
style Caddy fill:#fff,stroke:#333
style Pihole fill:#fff,stroke:#333
style DNSCrypt fill:#fff,stroke:#333
style Bridge_Net fill:#f6ffed,stroke:#52c41a
Loading

🛠️ Services & IP Assignments

The following services are configured with static IPs in the 10.8.1.0/24 subnet:

ServiceInternal IPExternal URL (Example)Description
Pi-hole10.8.1.48pihole.pi.rahulja.inDNS Sinkhole & Ad Blocker
DNSCrypt-Proxy10.8.1.48dnscrypt.pi.rahulja.inEncrypted DNS Proxy
Immich10.8.1.6immich.pi.rahulja.inSelf-hosted Photo & Video Management
Transmission10.8.1.23trans.pi.rahulja.inTorrent Client
Paperless-ngx10.8.1.32pngx.pi.rahulja.inDocument Management System
Filebrowser10.8.1.34filebrowser.pi.rahulja.inWeb-based File Manager
Actual Budget10.8.1.3actual.pi.rahulja.inPersonal Budgeting
ezBookkeeping10.8.1.19ezbookkeeping.pi.rahulja.inPersonal Finance Manager
Tailscale10.8.1.48N/AVPN Mesh Network
Web Test10.8.1.49webtest.pi.rahulja.inConnectivity Test (Whoami)
N8n10.8.1.53n8n.pi.rahulja.inWorkflow Automation
SearXNG10.8.1.54searxng.pi.rahulja.inPrivacy-respecting Metasearch Engine
Paisa10.8.1.56paisa.pi.rahulja.inPersonal Finance Manager
Homepage10.8.1.57homepage.pi.rahulja.inModern Startpage
Stirling-PDF10.8.1.58pdf.pi.rahulja.inPowerful PDF Manipulation Tools

Note: Immich auxiliary services (ML, Redis, DB) occupy IPs 10.8.1.8, 10.8.1.9, and 10.8.1.10 respectively.

⚙️ Configuration

Environment Variables

The setup relies heavily on environment variables for sensitive data and path configurations.

  1. Copy example.env to .env.
  2. Fill in the required fields, especially:
    • CLOUDFLARE_API_TOKEN (for Caddy SSL)
    • TAILSCALE_AUTH_KEY (for Tailscale connection)
    • Data paths (defaulting to /mnt/usb/...)
  3. Keep runtime env files local-only. .env, pihole.env, Pi-hole databases, and service state directories are intentionally ignored by git.

Runtime Config Files

  • pihole.env is the live Pi-hole local DNS host mapping source used by the Pi-hole container.
  • HOMEPAGE_CONFIG_PATH points to the live Homepage YAML directory mounted at /app/config.
  • Homepage widget credentials should be provided with HOMEPAGE_VAR_* values from .env; do not hardcode secrets into Homepage YAML.
  • Caddy admin is bound to localhost:2019. Dashboard entries should not rely on reaching the Caddy admin API from another container.

Networking

  • Network Name:wg-easy
  • Subnet:10.8.1.0/24
  • Gateway:10.8.1.1 (Default Docker bridge gateway)

Storage

Most heavy data (media, databases) is mapped to an external USB drive mounted at /mnt/usb. Ensure this mount point exists and has correct permissions, or update the .env file to point to your desired locations.

📦 Usage

  1. Clone the repository:

    git clone <repository-url>cd<repository-directory>
  2. Prepare Environment:

    cp example.env .env
    # Edit .env with your specific configuration
    nano .env
  3. Start Services:

    docker compose up -d

    Lazy services use Compose profiles. To start those services too:

    docker compose --profile lazy up -d
  4. Access Services: Open your browser and navigate to the configured domains (e.g., https://homepage.pi.rahulja.in). Ensure your DNS (likely Pi-hole) is correctly pointing these domains to your Nginx/Caddy instance or that you have local host entries if testing offline.

📝 Notes

  • Caddy & Tailscale: Caddy is configured with network_mode: service:tailscale, sharing the Tailscale container's network namespace. This allows Caddy to seamlessly serve content over the Tailscale mesh network and resolve internal IPs on the wg-easy bridge.

  • Internal DNS: All application containers are configured with dns: 10.8.1.48, ensuring they use Pi-hole for both internal and external name resolution.

  • Immich: Requires a significant amount of RAM for machine learning tasks.

  • Extended Documentation: Detailed architecture diagrams in .drawio and .svg formats can be found in the docs/ directory.

✅ Validation

Run these checks before and after config changes:

docker compose config
docker compose config --no-interpolate
bash scripts/audit-config.sh

For Caddy changes, validate with the project image because it includes the Cloudflare DNS and Sablier modules:

docker compose build caddy
docker compose run --rm --no-deps caddy caddy validate --config /etc/caddy/Caddyfile

Use git status --short --ignored to confirm runtime files remain ignored.

About

Docker compose and realted files for setting up pi with local data

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages