Add Uptime Kuma deployment

This commit is contained in:
2026-06-17 11:13:31 +03:30
commit 8f1e23f3cb
6 changed files with 177 additions and 0 deletions

6
.env.example Normal file
View File

@@ -0,0 +1,6 @@
# Uptime Kuma listens on container port 3001.
# Keep this enabled for standalone/direct access, even when Caddy is also used.
UPTIME_KUMA_HOST_PORT=3001
# Public URL used in documentation and run output.
UPTIME_KUMA_PUBLIC_URL=https://uptime.amiirkhl.ir

6
.gitattributes vendored Normal file
View File

@@ -0,0 +1,6 @@
*.sh text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.md text eol=lf
*.example text eol=lf
.gitignore text eol=lf

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
.env
# Runtime data, backups, and local OS files
data/
backups/
*.tar.gz
*.sql
.DS_Store
Thumbs.db

66
README.md Normal file
View File

@@ -0,0 +1,66 @@
# Uptime Kuma Deployment
Docker Compose deployment for [Uptime Kuma](https://github.com/louislam/uptime-kuma).
This repo can run by itself on port `3001` and can also be reverse proxied by the sibling `caddy-deployment` repo over the shared `caddy_proxy` Docker network.
## Quick Start
```bash
git clone http://git.amiirkhl.ir/interanet/uptime-kuma-deployment.git
cd uptime-kuma-deployment
chmod +x run.sh
./run.sh
```
The first run creates `.env` from `.env.example`.
## Standalone Access
By default Uptime Kuma is available directly at:
```text
http://SERVER_IP:3001
```
Change the host port in `.env` if needed:
```env
UPTIME_KUMA_HOST_PORT=3001
```
## Caddy Integration
The compose file attaches `uptime-kuma` to the external Docker network named `caddy_proxy`.
`run.sh` creates that network if it does not already exist, so the stack can start even before `caddy-deployment` is running.
The sibling `caddy-deployment/config/caddy/Caddyfile` includes:
```caddyfile
uptime.amiirkhl.ir {
import {$CADDY_TLS_MODE:custom_tls}
reverse_proxy uptime-kuma:3001
}
```
Start or reload Caddy after starting Uptime Kuma:
```bash
cd ../caddy-deployment
docker compose up -d
docker compose exec caddy caddy reload --config /etc/caddy/Caddyfile
```
## Data
Uptime Kuma data is stored in the Docker volume `uptime-kuma-deployment_uptime_kuma_data`.
Useful commands:
```bash
docker compose logs -f
docker compose pull
docker compose up -d
docker compose down
```

32
docker-compose.yml Normal file
View File

@@ -0,0 +1,32 @@
networks:
uptime_kuma:
driver: bridge
caddy_proxy:
external: true
volumes:
uptime_kuma_data:
services:
uptime-kuma:
image: louislam/uptime-kuma:2
container_name: uptime-kuma
restart: unless-stopped
ports:
- "${UPTIME_KUMA_HOST_PORT:-3001}:3001"
volumes:
- uptime_kuma_data:/app/data
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- uptime_kuma
- caddy_proxy
healthcheck:
test:
[
"CMD-SHELL",
"node -e \"fetch('http://127.0.0.1:3001').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""
]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s

58
run.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -euo pipefail
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo ""
echo "========================================"
echo " Uptime Kuma Deployment Bootstrapper"
echo "========================================"
echo ""
if ! command -v docker >/dev/null 2>&1; then
echo -e "${RED}[ERROR] Docker is not installed or not in PATH.${NC}"
exit 1
fi
if ! docker compose version >/dev/null 2>&1; then
echo -e "${RED}[ERROR] Docker Compose v2 is not available.${NC}"
exit 1
fi
if [ ! -f ".env" ]; then
echo -e "${YELLOW}[INFO] .env file not found. Creating one from .env.example.${NC}"
cp .env.example .env
fi
# Docker Compose requires external networks to exist before startup.
if ! docker network inspect caddy_proxy >/dev/null 2>&1; then
echo -e "${YELLOW}[INFO] Creating shared Docker network: caddy_proxy${NC}"
docker network create caddy_proxy >/dev/null
fi
set -a
source .env
set +a
echo "[STEP] Pulling images..."
docker compose pull
echo "[STEP] Starting Uptime Kuma..."
docker compose up -d
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Uptime Kuma deployment started${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Direct access:"
echo " http://localhost:${UPTIME_KUMA_HOST_PORT:-3001}"
echo ""
echo "Caddy access:"
echo " ${UPTIME_KUMA_PUBLIC_URL:-https://uptime.amiirkhl.ir}"
echo ""
echo "Container status:"
docker compose ps