203 lines
6.2 KiB
Markdown
203 lines
6.2 KiB
Markdown
# OpenClaw Homelab Stack
|
|||
|
|
|
||
|
|
Docker Compose deployment for OpenClaw, WireGuard UI (wg-easy), Gitea, Nginx Proxy Manager, and MariaDB.
|
||
|
|
|
||
|
|
The Compose file is [compose.yaml](./compose.yaml).
|
||
|
|
|
||
|
|
## Requirements
|
||
|
|
|
||
|
|
- Debian 12 or another Linux host
|
||
|
|
- Public DNS name or static public IP for WireGuard
|
||
|
|
- At least 2 GB RAM recommended
|
||
|
|
- Available host ports: 80/tcp, 443/tcp, 81/tcp, 51820/udp, 18789/tcp, 3000/tcp, 2222/tcp, and 51821/tcp
|
||
|
|
|
||
|
|
## Install Docker Engine and Compose
|
||
|
|
|
||
|
|
Run as root or an account with sudo access:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
sudo apt-get update
|
||
|
|
sudo apt-get install -y ca-certificates curl
|
||
|
|
sudo install -m 0755 -d /etc/apt/keyrings
|
||
|
|
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
||
|
|
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||
|
|
sudo apt-get update
|
||
|
|
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||
|
|
sudo systemctl enable --now docker
|
||
|
|
sudo usermod -aG docker "$USER"
|
||
|
|
```
|
||
|
|
|
||
|
|
Log out and back in, then verify:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker version
|
||
|
|
docker compose version
|
||
|
|
```
|
||
|
|
|
||
|
|
This OpenClaw workspace has no root or sudo, so Docker Engine cannot be installed directly here. A standalone Compose CLI at .local/bin/docker-compose can validate YAML but cannot start containers without a Docker daemon.
|
||
|
|
|
||
|
|
## Configure secrets and host settings
|
||
|
|
|
||
|
|
From the directory containing docker-compose.yaml, create .env:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cat > .env <<'EOF'
|
||
|
|
TZ=UTC
|
||
|
|
OPENCLAW_PORT=18789
|
||
|
|
|
||
|
|
# Public WireGuard endpoint
|
||
|
|
WG_HOST=vpn.example.com
|
||
|
|
WG_PORT=51820
|
||
|
|
WG_UI_PORT=51821
|
||
|
|
WG_UI_USERNAME=admin
|
||
|
|
WG_UI_PASSWORD=replace-with-a-long-random-password
|
||
|
|
|
||
|
|
# Gitea
|
||
|
|
GITEA_DOMAIN=git.example.com
|
||
|
|
GITEA_ROOT_URL=https://git.example.com/
|
||
|
|
GITEA_HTTP_PORT=3000
|
||
|
|
GITEA_SSH_PORT=2222
|
||
|
|
|
||
|
|
# Nginx Proxy Manager database
|
||
|
|
NPM_DB_NAME=npm
|
||
|
|
NPM_DB_USER=npm
|
||
|
|
NPM_DB_PASSWORD=replace-with-a-long-random-password
|
||
|
|
NPM_DB_ROOT_PASSWORD=replace-with-a-different-long-random-password
|
||
|
|
NPM_HTTP_PORT=80
|
||
|
|
NPM_ADMIN_PORT=81
|
||
|
|
NPM_HTTPS_PORT=443
|
||
|
|
EOF
|
||
|
|
chmod 600 .env
|
||
|
|
```
|
||
|
|
|
||
|
|
Use unique random values and never commit .env to Git.
|
||
|
|
|
||
|
|
## Validate and start
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker compose config --quiet
|
||
|
|
docker compose pull
|
||
|
|
docker compose up -d
|
||
|
|
docker compose ps
|
||
|
|
docker compose logs -f --tail=100
|
||
|
|
```
|
||
|
|
|
||
|
|
The first startup may take a few minutes while images download and MariaDB initializes.
|
||
|
|
|
||
|
|
## Initial access
|
||
|
|
|
||
|
|
- Nginx Proxy Manager: http://SERVER_IP:81
|
||
|
|
- Default email: admin@example.com
|
||
|
|
- Default password: changeme
|
||
|
|
- Change both immediately.
|
||
|
|
- Gitea: http://SERVER_IP:3000
|
||
|
|
- WireGuard UI: http://SERVER_IP:51821
|
||
|
|
- OpenClaw gateway: http://SERVER_IP:18789 if configured for HTTP access.
|
||
|
|
|
||
|
|
For internet-facing deployments, place Gitea, OpenClaw, and the WireGuard UI behind Nginx Proxy Manager with HTTPS. Do not expose admin interfaces publicly without authentication and TLS.
|
||
|
|
|
||
|
|
## Configure Nginx Proxy Manager
|
||
|
|
|
||
|
|
1. Log in at port 81 and change the default credentials.
|
||
|
|
2. Create Proxy Hosts for the services you want to publish.
|
||
|
|
3. On the Compose network, use these forward hosts:
|
||
|
|
- gitea:3000
|
||
|
|
- openclaw:18789
|
||
|
|
- wireguard-ui:51821
|
||
|
|
4. Request Let's Encrypt certificates and enable Force SSL.
|
||
|
|
|
||
|
|
WireGuard itself remains UDP on 51820; proxying the web UI does not replace that port.
|
||
|
|
|
||
|
|
## Firewall example
|
||
|
|
|
||
|
|
Open only the ports required by your deployment:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
sudo ufw allow 80/tcp
|
||
|
|
sudo ufw allow 443/tcp
|
||
|
|
sudo ufw allow 51820/udp
|
||
|
|
sudo ufw enable
|
||
|
|
```
|
||
|
|
|
||
|
|
Do not expose ports 81, 18789, 3000, 2222, or 51821 to the whole internet unless needed. Restrict them to your management network or VPN.
|
||
|
|
|
||
|
|
## Updates and shutdown
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker compose pull
|
||
|
|
docker compose up -d
|
||
|
|
docker image prune
|
||
|
|
```
|
||
|
|
|
||
|
|
Stop without deleting data:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker compose down
|
||
|
|
```
|
||
|
|
|
||
|
|
Never use docker compose down -v unless you intentionally want to delete persistent application data. Back up named volumes before upgrades.
|
||
|
|
|
||
|
|
## Backups
|
||
|
|
|
||
|
|
Back up these data sets:
|
||
|
|
|
||
|
|
- OpenClaw configuration and data
|
||
|
|
- WireGuard configuration and keys
|
||
|
|
- Gitea repositories and /data
|
||
|
|
- Nginx Proxy Manager /data and /etc/letsencrypt
|
||
|
|
- Nginx Proxy Manager MariaDB data
|
||
|
|
|
||
|
|
List volumes with:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker volume ls | grep -E 'openclaw|wireguard|gitea|npm'
|
||
|
|
```
|
||
|
|
|
||
|
|
## Troubleshooting
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker compose ps
|
||
|
|
docker compose logs -f openclaw
|
||
|
|
docker compose logs -f wireguard-ui
|
||
|
|
docker compose logs -f gitea
|
||
|
|
docker compose logs -f nginx-proxy-manager
|
||
|
|
```
|
||
|
|
|
||
|
|
After changing .env or the Compose file:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker compose up -d --force-recreate
|
||
|
|
```
|
||
|
|
|
||
|
|
If a port is already in use, change the host-side variable in .env and rerun deployment. Keep container-side ports in docker-compose.yaml unchanged.
|
||
|
|
## Automated configuration tests
|
||
|
|
|
||
|
|
Gitea Actions runs `.gitea/workflows/test.yml` on every push, pull request,
|
||
|
|
and manual dispatch. It requires a Linux x86-64 runner labelled
|
||
|
|
`ubuntu-latest`, with outbound HTTPS access to GitHub for pinned tooling.
|
||
|
|
|
||
|
|
This repository contains deployment configuration, not application source.
|
||
|
|
The five Python standard-library tests validate the actual Compose schema,
|
||
|
|
service inventory and persistent storage, database health dependency,
|
||
|
|
WireGuard UI binding/TLS setting and UDP port, custom port/database settings,
|
||
|
|
and rejection of missing database passwords. There is no application build,
|
||
|
|
linter or existing application test suite to run.
|
||
|
|
|
||
|
|
Run the same checks locally with Python 3.13.9 and Docker Compose v5.6.1:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
COMPOSE_BINARY=/absolute/path/to/docker-compose python3 scripts/test_compose.py
|
||
|
|
```
|
||
|
|
|
||
|
|
`COMPOSE_BINARY` must point to the standalone Compose CLI (the Docker CLI
|
||
|
|
plugin binary also works). CI verifies its pinned SHA-256 before execution.
|
||
|
|
No Python packages, Docker daemon, production credentials or deployed services
|
||
|
|
are needed. Tests use a temporary copy of `compose.yaml`, an empty env file,
|
||
|
|
a clean subprocess environment and synthetic passwords; the repository's
|
||
|
|
`.env` is never loaded. Nothing is started, pulled or deployed by the tests.
|
||
|
|
These are configuration regression checks, not live integration/health tests.
|
||
|
|
|
||
|
|
The workflow has a ten-minute timeout, read-only contents permissions and no
|
||
|
|
persisted checkout credentials. Use an isolated, unprivileged runner for
|
||
|
|
untrusted pull requests; do not mount production secrets or a Docker socket.
|