Files
ipmi-monitor/docker-compose.yml
T
cnbugs 9bf8b2e65f fix: 后端容器挂载 frontend/dist;更新文档补两个生产坑
- docker-compose.yml:backend 加挂 ./frontend/dist:/app/frontend/dist:ro,
  否则后端只提供 API 不提供前端,刷新 SPA 路由报 {"detail":"Not Found"}。
- PRODUCTION_UPDATE.md 常见问题补三条:readonly database(非 root
  appuser 写不动旧 root 建的数据卷,宿主机 chown -R 999:999)、
  前端 404(缺 dist 挂载)、组件在位 Raw IPMI data file not found
  (旧版写 /tmp,重启即丢,新版已存持久卷)。
2026-11-16 13:09:54 +08:00

77 lines
2.8 KiB
YAML

version: "3.8"
name: ${COMPOSE_PROJECT_NAME:-ipmi-monitor}
services:
influxdb:
image: influxdb:2.7
container_name: ipmi-influxdb
ports:
- "${INFLUXDB_PORT:-8086}:8086"
volumes:
- ./data/influxdb:/var/lib/influxdb2
environment:
- TZ=Asia/Shanghai
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_USERNAME:-admin}
# Required: no default is shipped; Compose refuses to start without them.
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_PASSWORD:?must be set}
- DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_ORG:-ipmi-monitor}
- DOCKER_INFLUXDB_INIT_BUCKET=${INFLUXDB_BUCKET:-metrics}
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUXDB_TOKEN:?must be set}
restart: unless-stopped
healthcheck:
test: ["CMD", "influx", "ping"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
backend:
image: ipmi-monitor-backend:latest
build:
context: ./backend
dockerfile: Dockerfile
container_name: ipmi-backend
ports:
- "${BACKEND_PORT:-8000}:8000"
volumes:
- backend-data:/app/data
- ./frontend/dist:/app/frontend/dist:ro
environment:
- TZ=Asia/Shanghai
- ENVIRONMENT=${ENVIRONMENT:-production}
# Required: the backend refuses to start without a JWT secret of at
# least 32 characters. Generate one and set it in .env.
- JWT_SECRET_KEY=${JWT_SECRET_KEY:?must be set}
# Required on first boot only (empty user table): password for the
# initial admin account (at least 12 characters). Ignored afterwards.
- ADMIN_INITIAL_PASSWORD=${ADMIN_INITIAL_PASSWORD:-}
# Optional: Fernet key for encrypting stored BMC/SMTP/Feishu secrets.
# When unset, the backend generates one and persists it next to the DB.
- CREDENTIAL_ENCRYPTION_KEY=${CREDENTIAL_ENCRYPTION_KEY:-}
# Optional: comma-separated CORS allow-list. Empty = no CORS (same-origin).
- CORS_ORIGINS=${CORS_ORIGINS:-}
- INFLUXDB_URL=http://influxdb:8086
- INFLUXDB_TOKEN=${INFLUXDB_TOKEN:?must be set}
- INFLUXDB_ORG=${INFLUXDB_ORG:-ipmi-monitor}
- INFLUXDB_BUCKET=${INFLUXDB_BUCKET:-metrics}
- POLL_INTERVAL=${POLL_INTERVAL:-60}
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- DATABASE_URL=${DATABASE_URL:-sqlite+aiosqlite:///./data/ipmi_monitor.db}
- REQUIRE_EXISTING_DATABASE=${REQUIRE_EXISTING_DATABASE:-false}
- MIN_EXPECTED_HOSTS=${MIN_EXPECTED_HOSTS:-0}
- SMTP_HOST=${SMTP_HOST:-}
- SMTP_PORT=${SMTP_PORT:-587}
- SMTP_USER=${SMTP_USER:-}
- SMTP_PASSWORD=${SMTP_PASSWORD:-}
depends_on:
influxdb:
condition: service_healthy
restart: unless-stopped
volumes:
influxdb-data:
driver: local
backend-data:
driver: local