feat(deploy): Docker Compose setup for one host #140

Merged
Sebi merged 1 commits from feat/compose into main 2026-11-23 20:54:14 +00:00
5 changed files with 197 additions and 0 deletions

No files matched your search

+11
View File
@@ -123,6 +123,17 @@ All settings are environment variables; [`.env.example`](.env.example) lists the
- `UPTIME_TRUSTED_PROXIES` must name your reverse proxy, or client addresses in the audit log and rate limits will be the proxy's.
- `UPTIME_RETENTION_*` set how long results, aggregates, audit entries and captured responses are kept.
### Docker Compose
[`deploy/compose`](deploy/compose) runs everything on one host: the console and API, a migration step before it starts, and optionally TimescaleDB, Redis, a checker and a status page server, each chosen through `COMPOSE_PROFILES` in `.env`:
```sh
cp .env.example .env && chmod 600 .env # fill in UPTIME_PUBLIC_URL, UPTIME_SECRET_KEYS and the passwords
docker compose up -d
```
Leave `db` and `redis` out of the profiles and set `UPTIME_DATABASE_URL` and `UPTIME_REDIS_URL` to use your own. The checker and status page server need a token, created with `docker compose exec api api agent create …` (the comments in `.env.example` show how). Containers run with a read-only root filesystem and without capabilities.
### Kubernetes
The Helm chart in [`deploy/helm/uptimesebi`](deploy/helm/uptimesebi) runs the console and API, and optionally a checker and status page servers in the cluster. Bring your own PostgreSQL with TimescaleDB and your own Redis (directly or through Sentinel). Each release publishes the chart:
+1
View File
@@ -21,6 +21,7 @@ import (
const usage = `usage:
api [serve]
api migrate up|down|status
api health
api admin grant|revoke <email>
api region add <key> [name]
api agent create --kind checker|statuspage [--region <key>] --name <name>
+3
View File
@@ -48,6 +48,9 @@ func run(log *slog.Logger, level *slog.LevelVar, args []string) error {
return migrate(ctx, log, cfg, args[1:])
case "admin", "agent", "region":
return admin(ctx, cfg, args)
case "health":
// The image has no shell; Docker's HEALTHCHECK runs this.
return platform.ProbeLocal(ctx, cfg.Listen, "/healthz")
case "serve":
default:
return usageError{}
+40
View File
@@ -0,0 +1,40 @@
# Settings for compose.yaml; copy to .env (chmod 600) and fill in.
# Parts to run: db and redis bundle TimescaleDB and Redis, checker and
# statuspage add a checker and a status page server on this host.
COMPOSE_PROFILES=db,redis
# Image and channel: latest (releases), beta, edge (main), or a version.
UPTIME_TAG=latest
# UPTIME_IMAGE=git.zb-server.de/zb-server/uptimesebi
# Address users reach the console at.
UPTIME_PUBLIC_URL=http://localhost:8080
UPTIME_PORT=8080
# Encrypts stored secrets; generate with: echo "k1:$(head -c32 /dev/urandom | base64)"
UPTIME_SECRET_KEYS=
# first-user, open or closed.
UPTIME_SIGNUP=first-user
# UPTIME_SMTP_URL=smtp://user:pass@host:587?from=alerts@example.com
# Address of a reverse proxy in front, e.g. 172.16.0.0/12 for one in Docker.
# UPTIME_TRUSTED_PROXIES=
# Bundled database and Redis (profiles db and redis); generate with:
# head -c24 /dev/urandom | base64 | tr -d '/+='
POSTGRES_PASSWORD=
REDIS_PASSWORD=
# Or your own; then drop db and redis from COMPOSE_PROFILES.
# UPTIME_DATABASE_URL=postgres://uptime:...@db.example.com:5432/uptime?sslmode=require
# UPTIME_REDIS_URL=redis://:...@redis.example.com:6379/0
# Checker on this host (profile checker); token from:
# docker compose exec api api region add <key> <name>
# docker compose exec api api agent create --kind checker --region <key> --name <name>
# UPTIME_CHECKER_TOKEN=
# Status page server on this host (profile statuspage); token from:
# docker compose exec api api agent create --kind statuspage --name <name>
# UPTIME_STATUSPAGE_TOKEN=
# UPTIME_STATUSPAGE_HOSTS=status.example.com
# UPTIME_STATUSPAGE_PORT=8082
# UPTIME_STATUSPAGE_URL=https://status.example.com
+142
View File
@@ -0,0 +1,142 @@
# UptimeSebi on one host with Docker Compose. Copy .env.example to .env,
# fill it in and run: docker compose up -d
#
# COMPOSE_PROFILES in .env picks the parts: db and redis bundle TimescaleDB
# and Redis (leave them out and set UPTIME_DATABASE_URL / UPTIME_REDIS_URL
# to use your own), checker and statuspage add a checker and a status page
# server on this host. To switch a part off again, take it out of
# COMPOSE_PROFILES and remove its container: docker compose rm -sf checker
x-image: &image ${UPTIME_IMAGE:-git.zb-server.de/zb-server/uptimesebi}:${UPTIME_TAG:-latest}
x-platform: &platform
UPTIME_PUBLIC_URL: ${UPTIME_PUBLIC_URL:?set UPTIME_PUBLIC_URL in .env}
UPTIME_SECRET_KEYS: ${UPTIME_SECRET_KEYS:?set UPTIME_SECRET_KEYS in .env}
UPTIME_DATABASE_URL: ${UPTIME_DATABASE_URL:-postgres://uptime:${POSTGRES_PASSWORD:-}@db:5432/uptime?sslmode=disable}
UPTIME_REDIS_URL: ${UPTIME_REDIS_URL:-redis://:${REDIS_PASSWORD:-}@redis:6379/0}
UPTIME_SIGNUP: ${UPTIME_SIGNUP:-first-user}
UPTIME_SMTP_URL: ${UPTIME_SMTP_URL:-}
UPTIME_STATUSPAGE_URL: ${UPTIME_STATUSPAGE_URL:-}
UPTIME_TRUSTED_PROXIES: ${UPTIME_TRUSTED_PROXIES:-}
UPTIME_AGENT_IMAGE: ${UPTIME_IMAGE:-git.zb-server.de/zb-server/uptimesebi}
UPTIME_LOG_LEVEL: ${UPTIME_LOG_LEVEL:-info}
x-logging: &logging
driver: json-file
options:
max-size: 10m
max-file: "3"
x-hardening: &hardening
read_only: true
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
tmpfs: [/tmp]
services:
db:
profiles: [db]
image: timescale/timescaledb:2.30.1-pg16
restart: unless-stopped
environment:
POSTGRES_USER: uptime
POSTGRES_DB: uptime
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-}
volumes:
- db:/var/lib/postgresql/data
healthcheck:
test: [CMD, pg_isready, -U, uptime, -d, uptime]
interval: 5s
timeout: 5s
retries: 30
logging: *logging
redis:
profiles: [redis]
image: redis:8-alpine
restart: unless-stopped
command: [redis-server, --requirepass, "${REDIS_PASSWORD:-}", --appendonly, "yes", --save, ""]
environment:
REDISCLI_AUTH: ${REDIS_PASSWORD:-}
volumes:
- redis:/data
healthcheck:
test: [CMD, redis-cli, ping]
interval: 5s
timeout: 5s
retries: 30
logging: *logging
# Applies the schema before the API starts, on every docker compose up.
migrate:
image: *image
command: [migrate, up]
restart: "no"
environment: *platform
depends_on:
db:
condition: service_healthy
required: false
<<: *hardening
logging: *logging
api:
image: *image
restart: unless-stopped
environment: *platform
ports:
- "${UPTIME_PORT:-8080}:8080"
depends_on:
migrate:
condition: service_completed_successfully
redis:
condition: service_healthy
required: false
healthcheck:
test: [CMD, /usr/local/bin/api, health]
interval: 30s
timeout: 5s
start_period: 20s
<<: *hardening
logging: *logging
# Create its token first, then set UPTIME_CHECKER_TOKEN:
# docker compose exec api api region add <key> <name>
# docker compose exec api api agent create --kind checker --region <key> --name <name>
checker:
profiles: [checker]
image: ${UPTIME_IMAGE:-git.zb-server.de/zb-server/uptimesebi}-checker:${UPTIME_TAG:-latest}
restart: unless-stopped
environment:
UPTIME_API_URL: http://api:8080
UPTIME_AGENT_TOKEN: ${UPTIME_CHECKER_TOKEN:-}
UPTIME_LOG_LEVEL: ${UPTIME_LOG_LEVEL:-info}
depends_on:
api:
condition: service_healthy
<<: *hardening
logging: *logging
# Create its token first, then set UPTIME_STATUSPAGE_TOKEN:
# docker compose exec api api agent create --kind statuspage --name <name>
statuspage:
profiles: [statuspage]
image: ${UPTIME_IMAGE:-git.zb-server.de/zb-server/uptimesebi}-statuspage:${UPTIME_TAG:-latest}
restart: unless-stopped
environment:
UPTIME_API_URL: http://api:8080
UPTIME_AGENT_TOKEN: ${UPTIME_STATUSPAGE_TOKEN:-}
UPTIME_STATUSPAGE_HOSTS: ${UPTIME_STATUSPAGE_HOSTS:-localhost}
UPTIME_TRUSTED_PROXIES: ${UPTIME_TRUSTED_PROXIES:-}
UPTIME_LOG_LEVEL: ${UPTIME_LOG_LEVEL:-info}
ports:
- "${UPTIME_STATUSPAGE_PORT:-8082}:8082"
volumes:
- statuspage:/var/lib/uptimesebi
depends_on:
api:
condition: service_healthy
<<: *hardening
logging: *logging
volumes:
db:
redis:
statuspage: