Scenario 1: container install and update (all-in-one and per-component)

- Variant B: docker-compose.yml gets configurable host ports and health
  checks. Variant A: deploy/allinone image (nginx, supervisord, gunicorn,
  uvicorn, gatherer, OpenVPN) with an explicit database migration step
  before any service; docker-compose.allinone.yml. Same five volumes and
  paths in both variants.
- deploy/docker: install.sh, update.sh (backup, build, stop, separate DB
  migration phase, start, automatic rollback), backup.sh, restore.sh, lib.sh.
- Verified on Docker: install A/B, update with pre-versioned databases,
  rollback after an injected failure, backup/restore.
- Docs: Scenario1_Containers guide, change summary, README, Index;
  .dockerignore, .gitignore additions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-05 09:24:55 +03:00
1 parent e556d6d4b9
commit 1c49d0b9c2
17 files changed
+1930 -50

No files matched your search

+4 -47
View File
@@ -1,53 +1,10 @@
# Deployment: Docker
Uses `docker-compose.yml` from the repository root.
The container deployment (all components in one container, or one container per component), its install and update scripts, backup and rollback are described in **[Scenario 1: installation in containers](../Deployment/Scenario1_Containers.md)**.
## Services
| Service | Container | Ports | Notes |
|---|---|---|---|
| `app-ui` | `ovp-ui` | 80 | Nginx + built UI; proxies `/api/` and `/profiles-api/` |
| `app-api` | `ovp-api` | 5001 | Flask monitoring API |
| `app-gatherer` | `ovp-gatherer` | - | Parses `openvpn-status.log` |
| `app-profiler` | `ovp-profiler` | 8000, 1194/udp | FastAPI + OpenVPN; needs `NET_ADMIN` and `/dev/net/tun` |
Volumes: `ovp_logs`, `ovp_config`, `ovp_pki`, `ovp_client_config`, `db_data`.
## Steps
1. Create `.env` next to `docker-compose.yml` (`JWT_SECRET` is mandatory: compose refuses to start without it):
```bash
cat > .env <<EOT
JWT_SECRET=$(openssl rand -hex 32)
OVPMON_INITIAL_ADMIN_USER=<login>
OVPMON_INITIAL_ADMIN_PASSWORD=<strong password>
EOT
chmod 600 .env
```
2. `docker-compose up -d --build`
3. Open `http://<host>`, sign in, **PKI Configuration → Initialize PKI**.
4. Remove `OVPMON_INITIAL_ADMIN_*` from `.env` and run `docker-compose up -d app-api` (the seed is used only while the users table is empty).
## Compose settings
| Item | Value |
|---|---|
| Published ports | `80/tcp` (UI) and `1194/udp` (VPN) only; `5001` and `8000` are `expose`d on `ovp-net` and reached through Nginx in `app-ui` |
| Secrets | `JWT_SECRET` (required) → `OVPMON_API_SECRET_KEY` for both APIs |
| Initial admin | `OVPMON_INITIAL_ADMIN_USER` / `OVPMON_INITIAL_ADMIN_PASSWORD` (optional, first start) |
| CORS | `OVPMON_CORS_ORIGINS` (optional, comma-separated; off by default because the UI is same-origin) |
| Restart policy | `unless-stopped` |
## Hardening
- Terminate TLS in front of `app-ui` (reverse proxy or a certificate mounted into the UI container); see [Nginx configuration](Nginx_Configuration.md). The container serves plain HTTP on 80.
- `ovp-profiler` is privileged (`NET_ADMIN`, TUN): keep its API off the host network.
- Back up the `db_data` and `ovp_pki` volumes; never commit `.env`.
## Operations
Quick start (variant B, one container per component, `docker-compose.yml`):
```bash
docker-compose ps
docker-compose logs -f app-api app-profiler
docker-compose up -d --build app-ui # after UI changes
deploy/docker/install.sh --variant b # variant A (one container): --variant a
deploy/docker/update.sh # later updates: backup, build, separate database migration, start
```
+1
View File
@@ -24,6 +24,7 @@ Welcome to the documentation for the OpenVPN Monitor suite.
- [Toast notifications (2026-10-04)](../Changes/2026-10-04_Toast_Notifications.md)
- [PKI dependency guard (2026-10-04)](../Changes/2026-10-04_PKI_Dependency_Guard.md)
- [Database migrations (2026-10-05)](../Changes/2026-10-05_DB_Migrations.md) · [reference](Database_Migrations.md)
- [Scenario 1: containers (2026-10-05)](../Changes/2026-10-05_Scenario1_Containers.md) · [guide](../Deployment/Scenario1_Containers.md)
## 🔍 Core Monitoring (`APP_CORE`)
The core module responsible for log parsing, real-time statistics, and the primary API.