wxcc-monitor/docker-compose.yml
jmcqueen 935c27854b Initial commit with Docker deployment support.
Containerize the monitor with production and dev compose stacks, fix healthchecks and port handling, and make the dashboard base path configurable for direct or proxied access.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 08:04:02 -04:00

85 lines
2.8 KiB
YAML

# =============================================================================
# wxcc-monitor - Production Docker Compose
#
# Usage (recommended):
# docker compose -f docker-compose.yml --env-file .env.prod up -d
#
# This file is intentionally minimal and production-focused.
# - Uses bind mounts (not named volumes) for data/ and logs/ as requested.
# - Expects all secrets via --env-file (e.g. .env.prod)
# - Healthcheck + restart policy enabled
# - No dev tools, no source code mounts
# =============================================================================
services:
app:
build:
context: .
dockerfile: Dockerfile
target: final
container_name: wxcc-monitor-prod
restart: unless-stopped
# All secrets and configuration come from an external env file.
# Never commit real .env.prod to git.
env_file:
- .env.prod
# Container always listens on 3000 internally; host mapping below exposes 1912.
# Override PORT from .env.prod (often set to the host port for native dev).
environment:
PORT: "3000"
ports:
# Map host port to container port 3000.
# Change the left side as needed (e.g. "8080:3000").
- "1912:3000"
volumes:
# Bind-mount host directories for persistence (required).
# The application writes tokens, agent states, thresholds, logs, etc.
- ./data:/app/data
- ./logs:/app/logs
# Healthcheck uses the existing /health endpoint defined in the app.
healthcheck:
test: ["CMD", "node", "scripts/healthcheck.js"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
# Security: run as the non-root 'node' user defined in the Dockerfile
user: "1000:1000"
# Logging configuration (adjust to taste)
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Resource limits (tune for your environment)
# deploy:
# resources:
# limits:
# cpus: '1.0'
# memory: 512M
# =============================================================================
# Important Notes
#
# 1. The container always serves the application at the root path (/).
# Any /test prefix you see in the dashboard is added by your external
# reverse proxy (this is the intended deployment model).
#
# 2. You must mount ./data and ./logs. The app writes many JSON files
# (agentStates, tokens, active alerts, daily totals, etc.).
#
# 3. WEBHOOK_URL must be publicly reachable and point to your reverse proxy,
# which then forwards to this container.
#
# 4. Run with a dedicated .env.prod file so you can keep dev and prod
# configurations completely separate and run both stacks simultaneously
# if desired.
# =============================================================================