2026-09-30 12:14:22 +00:00
|
|
|
# OpenVPN Monitor & Profiler (containers)
|
|
|
|
|
# Required: JWT_SECRET in .env (openssl rand -hex 32)
|
|
|
|
|
# First start only: OVPMON_INITIAL_ADMIN_USER / OVPMON_INITIAL_ADMIN_PASSWORD in .env
|
|
|
|
|
# Optional: OVPMON_CORS_ORIGINS (comma-separated origins; off by default, UI is same-origin via Nginx)
|
2026-10-05 09:24:55 +03:00
|
|
|
# Optional: OVPMON_HTTP_PORT (host port of the UI, default 80), OVPMON_VPN_PORT (host UDP port of OpenVPN, default 1194)
|
2026-10-07 13:28:30 +03:00
|
|
|
# Optional: OVPMON_CSP_CONNECT_EXTRA (origins the UI may call besides its own, e.g. https://api.example.com; empty by default)
|
2026-10-05 20:30:45 +03:00
|
|
|
# Install/update with the scripts in deploy/docker (see DOCS/Deployment/Containers/README.md)
|
2026-09-30 12:14:22 +00:00
|
|
|
|
|
|
|
|
x-secret: &jwt-secret
|
|
|
|
|
OVPMON_API_SECRET_KEY: ${JWT_SECRET:?JWT_SECRET must be set in .env (openssl rand -hex 32)}
|
2026-02-05 07:36:25 +03:00
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
app-ui:
|
|
|
|
|
build: ./APP_UI
|
|
|
|
|
container_name: ovp-ui
|
2026-09-30 12:14:22 +00:00
|
|
|
restart: unless-stopped
|
2026-02-05 07:36:25 +03:00
|
|
|
ports:
|
2026-10-05 09:24:55 +03:00
|
|
|
- "${OVPMON_HTTP_PORT:-80}:80"
|
2026-02-05 07:36:25 +03:00
|
|
|
depends_on:
|
|
|
|
|
- app-api
|
|
|
|
|
- app-profiler
|
|
|
|
|
networks:
|
|
|
|
|
- ovp-net
|
2026-02-06 21:14:52 +03:00
|
|
|
environment:
|
2026-09-30 12:14:22 +00:00
|
|
|
OVP_API_HOST: ovp-api
|
|
|
|
|
OVP_API_PORT: 5001
|
|
|
|
|
OVP_PROFILER_HOST: ovp-profiler
|
|
|
|
|
OVP_PROFILER_PORT: 8000
|
2026-10-07 13:28:30 +03:00
|
|
|
# Extra connect-src origins of the CSP (API on another host), separated by spaces; empty = same origin only
|
|
|
|
|
OVP_CSP_CONNECT_EXTRA: ${OVPMON_CSP_CONNECT_EXTRA:-}
|
2026-10-05 09:24:55 +03:00
|
|
|
healthcheck:
|
|
|
|
|
# busybox wget exists in nginx:alpine
|
|
|
|
|
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/"]
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 3
|
|
|
|
|
start_period: 10s
|
2026-02-05 07:36:25 +03:00
|
|
|
|
|
|
|
|
app-gatherer:
|
|
|
|
|
build:
|
|
|
|
|
context: ./APP_CORE
|
|
|
|
|
dockerfile: Dockerfile.gatherer
|
|
|
|
|
container_name: ovp-gatherer
|
2026-09-30 12:14:22 +00:00
|
|
|
restart: unless-stopped
|
2026-02-05 07:36:25 +03:00
|
|
|
volumes:
|
|
|
|
|
- ovp_logs:/var/log/openvpn
|
2026-02-06 09:02:59 +03:00
|
|
|
- db_data:/app/db
|
2026-02-05 07:36:25 +03:00
|
|
|
depends_on:
|
|
|
|
|
- app-profiler
|
|
|
|
|
networks:
|
|
|
|
|
- ovp-net
|
2026-09-30 12:14:22 +00:00
|
|
|
environment:
|
|
|
|
|
OVPMON_OPENVPN_MONITOR_DB_PATH: /app/db/openvpn_monitor.db
|
|
|
|
|
OVPMON_OPENVPN_MONITOR_LOG_PATH: /var/log/openvpn/openvpn-status.log
|
|
|
|
|
OVPMON_LOGGING_LEVEL: INFO
|
2026-10-05 09:24:55 +03:00
|
|
|
healthcheck:
|
|
|
|
|
# Process check: the gatherer is PID 1 of its container (CMD python openvpn_gatherer_v3.py)
|
|
|
|
|
test: ["CMD", "python", "-c", "import sys; sys.exit(0 if b'openvpn_gatherer_v3.py' in open('/proc/1/cmdline', 'rb').read() else 1)"]
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 3
|
|
|
|
|
start_period: 30s
|
2026-02-05 07:36:25 +03:00
|
|
|
|
|
|
|
|
app-api:
|
|
|
|
|
build:
|
|
|
|
|
context: ./APP_CORE
|
|
|
|
|
dockerfile: Dockerfile.api
|
|
|
|
|
container_name: ovp-api
|
2026-09-30 12:14:22 +00:00
|
|
|
restart: unless-stopped
|
|
|
|
|
# Not published: reached only through app-ui (Nginx) on ovp-net
|
|
|
|
|
expose:
|
|
|
|
|
- "5001"
|
2026-02-05 07:36:25 +03:00
|
|
|
volumes:
|
|
|
|
|
- db_data:/app/db
|
|
|
|
|
networks:
|
|
|
|
|
- ovp-net
|
2026-02-06 09:02:59 +03:00
|
|
|
depends_on:
|
|
|
|
|
- app-gatherer
|
2026-09-30 12:14:22 +00:00
|
|
|
environment:
|
|
|
|
|
<<: *jwt-secret
|
|
|
|
|
OVPMON_API_PORT: 5001
|
|
|
|
|
OVPMON_OPENVPN_MONITOR_DB_PATH: /app/db/openvpn_monitor.db
|
|
|
|
|
OVPMON_LOGGING_LEVEL: INFO
|
|
|
|
|
# Initial admin: used only while the users table is empty (remove after first start)
|
|
|
|
|
OVPMON_INITIAL_ADMIN_USER: ${OVPMON_INITIAL_ADMIN_USER:-}
|
|
|
|
|
OVPMON_INITIAL_ADMIN_PASSWORD: ${OVPMON_INITIAL_ADMIN_PASSWORD:-}
|
|
|
|
|
OVPMON_CORS_ORIGINS: ${OVPMON_CORS_ORIGINS:-}
|
2026-10-05 09:24:55 +03:00
|
|
|
healthcheck:
|
|
|
|
|
# TCP connect to the Flask port
|
|
|
|
|
test: ["CMD", "python", "-c", "import socket; socket.create_connection(('127.0.0.1', 5001), 3).close()"]
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 3
|
|
|
|
|
start_period: 30s
|
2026-02-05 07:36:25 +03:00
|
|
|
|
|
|
|
|
app-profiler:
|
2026-10-07 09:38:09 +03:00
|
|
|
build:
|
|
|
|
|
context: ./APP_PROFILER
|
|
|
|
|
# Migration code of the monitoring database for the restore (docker compose 2.17 or newer)
|
|
|
|
|
additional_contexts:
|
|
|
|
|
core: ./APP_CORE
|
2026-02-05 07:36:25 +03:00
|
|
|
container_name: ovp-profiler
|
2026-09-30 12:14:22 +00:00
|
|
|
restart: unless-stopped
|
2026-02-05 07:36:25 +03:00
|
|
|
cap_add:
|
|
|
|
|
- NET_ADMIN
|
2026-02-07 14:07:47 +03:00
|
|
|
sysctls:
|
|
|
|
|
- net.ipv4.ip_forward=1
|
2026-02-05 07:36:25 +03:00
|
|
|
devices:
|
|
|
|
|
- "/dev/net/tun:/dev/net/tun"
|
|
|
|
|
ports:
|
2026-09-30 12:14:22 +00:00
|
|
|
# VPN port only; the profiler API (8000) is reached through app-ui
|
2026-10-05 09:24:55 +03:00
|
|
|
- "${OVPMON_VPN_PORT:-1194}:1194/udp"
|
2026-09-30 12:14:22 +00:00
|
|
|
expose:
|
|
|
|
|
- "8000"
|
2026-02-05 07:36:25 +03:00
|
|
|
volumes:
|
|
|
|
|
- ovp_logs:/var/log/openvpn
|
|
|
|
|
- ovp_config:/etc/openvpn
|
2026-02-07 14:01:20 +03:00
|
|
|
- db_data:/app/db
|
2026-02-07 22:40:40 +03:00
|
|
|
- ovp_client_config:/app/client-config
|
2026-02-07 14:30:45 +03:00
|
|
|
- ovp_pki:/app/easy-rsa
|
2026-10-07 09:38:09 +03:00
|
|
|
# Local backup packages (Backup and Restore page); not part of deploy/docker backup.sh
|
|
|
|
|
- ovp_backups:/app/backups
|
2026-02-05 07:36:25 +03:00
|
|
|
networks:
|
|
|
|
|
- ovp-net
|
|
|
|
|
environment:
|
2026-09-30 12:14:22 +00:00
|
|
|
<<: *jwt-secret
|
|
|
|
|
OVPMON_PROFILER_DB_PATH: /app/db/ovpn_profiler.db
|
2026-10-07 09:38:09 +03:00
|
|
|
OVPMON_BACKUP_LOCAL_ROOT: /app/backups
|
2026-09-30 12:14:22 +00:00
|
|
|
OVPMON_CORS_ORIGINS: ${OVPMON_CORS_ORIGINS:-}
|
2026-10-05 09:24:55 +03:00
|
|
|
healthcheck:
|
|
|
|
|
# GET / of the FastAPI app must answer 200
|
|
|
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/', timeout=3)"]
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 3
|
|
|
|
|
start_period: 40s
|
2026-02-05 07:36:25 +03:00
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
ovp-net:
|
|
|
|
|
driver: bridge
|
|
|
|
|
|
|
|
|
|
volumes:
|
|
|
|
|
ovp_logs:
|
|
|
|
|
ovp_config:
|
2026-02-07 14:16:49 +03:00
|
|
|
ovp_pki:
|
2026-02-07 22:40:40 +03:00
|
|
|
ovp_client_config:
|
2026-02-05 07:36:25 +03:00
|
|
|
db_data:
|
2026-10-07 09:38:09 +03:00
|
|
|
ovp_backups:
|