commit 8f1e23f3cbf40e298190f2c373c151832a2087a4 Author: Amirhossein Khalili Date: Wed Jun 17 11:13:31 2026 +0330 Add Uptime Kuma deployment diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..96fd459 --- /dev/null +++ b/.env.example @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0a05057 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7028a01 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.env + +# Runtime data, backups, and local OS files +data/ +backups/ +*.tar.gz +*.sql +.DS_Store +Thumbs.db diff --git a/README.md b/README.md new file mode 100644 index 0000000..a847161 --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8402a6e --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e861bfd --- /dev/null +++ b/run.sh @@ -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