-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
137 lines (133 loc) · 5.02 KB
/
Copy pathdocker-compose.yml
File metadata and controls
137 lines (133 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
services:
timescaledb:
image: timescale/timescaledb:2.25.2-pg16
container_name: stats-timescaledb
environment:
POSTGRES_DB: ${POSTGRES_DB:-gos_rem}
POSTGRES_USER: ${POSTGRES_USER:-gos}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me-in-production}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- timescaledb-data:/var/lib/postgresql/data
- ./scripts/init-timescaledb.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
ports:
- "${POSTGRES_PORT:-5432}:5432"
restart: always
networks:
- stats-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-gos} -d ${POSTGRES_DB:-gos_rem}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
collector:
image: ghcr.io/nebul2/rem-collector:latest
build:
context: .
dockerfile: app/Dockerfile
args:
GIT_SHA: ${GIT_SHA:-}
container_name: stats-collector
environment:
# TP-Link API credentials
- TPLINK_CLIENT_ID=${TPLINK_CLIENT_ID:?set TPLINK_CLIENT_ID in .env}
- TPLINK_CLIENT_SECRET=${TPLINK_CLIENT_SECRET:?set TPLINK_CLIENT_SECRET in .env}
- TPLINK_API_KEY=${TPLINK_API_KEY:?set TPLINK_API_KEY in .env}
- TPLINK_REFRESH_TOKEN=${TPLINK_REFRESH_TOKEN}
# PostgreSQL/TimescaleDB connection
- POSTGRES_HOST=timescaledb
- POSTGRES_PORT=5432
- POSTGRES_DB=${POSTGRES_DB:-gos_rem}
- POSTGRES_USER=${POSTGRES_USER:-gos}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-change-me-in-production}
# Collector settings
- POLL_INTERVAL=${POLL_INTERVAL:-30}
# Optional: override parallel_workers from collector_control.json (1–32)
# - COLLECTOR_PARALLEL_WORKERS=8
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- CONF_FILE=/app/config/config.yaml
- TOKEN_FILE=/app/data/refresh_token.txt
# Admin UI writes collector_control.json to admin-data; mount it here so the collector
# applies poll_interval / device_query_delay from the same file (see v1.4.6).
- COLLECTOR_CONTROL_FILE=/app/data/admin/collector_control.json
# Runtime status + reset_backoff touch file (collector writes status; reads reset flag)
- COLLECTOR_STATUS_FILE=/app/data/admin/collector_status.json
volumes:
- ./app/config:/app/config:ro
- collector-data:/app/data
- admin-data:/app/data/admin
depends_on:
timescaledb:
condition: service_healthy
restart: always
networks:
- stats-network
healthcheck:
test: ["CMD", "python", "-c", "import os; pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]; cmdlines = [open(f'/proc/{pid}/cmdline', 'rb').read().decode('utf-8', errors='ignore').replace(chr(0), ' ') for pid in pids if os.path.exists(f'/proc/{pid}/cmdline')]; exit(0 if any('collector.py' in cmd for cmd in cmdlines) else 1)"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
admin:
image: ghcr.io/nebul2/rem-admin:latest
build:
context: .
dockerfile: admin/Dockerfile
args:
GIT_SHA: ${GIT_SHA:-}
container_name: stats-admin
environment:
# PostgreSQL/TimescaleDB connection
- POSTGRES_HOST=timescaledb
- POSTGRES_PORT=5432
- POSTGRES_DB=${POSTGRES_DB:-gos_rem}
- POSTGRES_USER=${POSTGRES_USER:-gos}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-change-me-in-production}
- DATA_DIR=/app/data
# Optional HTTP Basic Auth for Admin UI
- ADMIN_BASIC_USER=${ADMIN_BASIC_USER}
- ADMIN_BASIC_PASSWORD=${ADMIN_BASIC_PASSWORD}
# Public base URL for LEM join codes (set on production; blank = derive from request)
- REM_PUBLIC_URL=${REM_PUBLIC_URL:-}
volumes:
- admin-data:/app/data
ports:
- "${ADMIN_PORT:-7001}:7001"
depends_on:
timescaledb:
condition: service_healthy
restart: always
networks:
- stats-network
# Uncomment the next line if using Traefik reverse proxy
# - traefik-network
# Uncomment the labels section below if using Traefik reverse proxy
# labels:
# - "traefik.enable=true"
# - "traefik.http.routers.stats.rule=Host(`rem.example.com`)"
# - "traefik.http.routers.stats.entrypoints=websecure"
# - "traefik.http.routers.stats.tls.certresolver=letsencrypt"
# - "traefik.http.services.stats.loadbalancer.server.port=7001"
# - "traefik.http.routers.stats.middlewares=stats-auth"
# - "traefik.http.middlewares.stats-auth.basicauth.usersfile=/etc/traefik/auth/users.txt"
# - "traefik.docker.network=traefik-network"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:7001/api/devices').read()"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
volumes:
collector-data:
driver: local
timescaledb-data:
driver: local
admin-data:
driver: local
networks:
stats-network:
driver: bridge
# Uncomment the network below if using Traefik reverse proxy
# traefik-network:
# external: true