-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
313 lines (253 loc) · 7.96 KB
/
docker-compose.yml
File metadata and controls
313 lines (253 loc) · 7.96 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
services:
# LabLink Server (FastAPI backend)
lablink-server:
build:
context: .
dockerfile: docker/Dockerfile.server
container_name: lablink-server
image: lablink-server:${LABLINK_VERSION:-latest}
restart: unless-stopped
ports:
- "${LABLINK_API_PORT:-8000}:8000" # REST API
- "${LABLINK_WS_PORT:-8001}:8001" # WebSocket
volumes:
# Persistent data
- lablink-data:/app/data
- lablink-logs:/app/logs
- lablink-backups:/app/backups
- lablink-states:/app/states
# Configuration (optional - mount your own config)
- ./config:/app/config:ro
# USB device identification via sysfs (needed for serial device VID:PID extraction)
- /sys:/sys:ro
# Pi-specific mounts for diagnostics (comment out these two lines for non-Pi development)
# These enable the Pi diagnostics feature to run scripts on the host system
- /var/run/docker.sock:/var/run/docker.sock:ro # Docker API access
- /opt/lablink:/opt/lablink:ro # Host LabLink directory
environment:
# Server configuration
- LABLINK_HOST=0.0.0.0
- LABLINK_SERVER_NAME=${LABLINK_SERVER_NAME:-LabLink Server}
- LABLINK_API_PORT=8000
- LABLINK_WS_PORT=8001
- LABLINK_DEBUG=${LABLINK_DEBUG:-false}
- LABLINK_LOG_LEVEL=${LABLINK_LOG_LEVEL:-INFO}
# Database
- LABLINK_DATABASE_PATH=/app/data/lablink.db
# Security
- LABLINK_JWT_SECRET_KEY=${LABLINK_JWT_SECRET_KEY}
- LABLINK_JWT_ACCESS_TOKEN_EXPIRE_MINUTES=${LABLINK_JWT_ACCESS_TOKEN_EXPIRE_MINUTES:-30}
- LABLINK_ENABLE_CORS=${LABLINK_ENABLE_CORS:-true}
# Advanced Security System
- LABLINK_ENABLE_ADVANCED_SECURITY=${LABLINK_ENABLE_ADVANCED_SECURITY:-true}
- LABLINK_CREATE_DEFAULT_ADMIN=${LABLINK_CREATE_DEFAULT_ADMIN:-true}
- LABLINK_DEFAULT_ADMIN_USERNAME=${LABLINK_DEFAULT_ADMIN_USERNAME:-admin}
- LABLINK_DEFAULT_ADMIN_PASSWORD=${LABLINK_DEFAULT_ADMIN_PASSWORD:-LabLink@2025}
- LABLINK_DEFAULT_ADMIN_EMAIL=${LABLINK_DEFAULT_ADMIN_EMAIL:-admin@example.com}
# OAuth2 (optional)
- LABLINK_OAUTH_GOOGLE_CLIENT_ID=${LABLINK_OAUTH_GOOGLE_CLIENT_ID:-}
- LABLINK_OAUTH_GOOGLE_CLIENT_SECRET=${LABLINK_OAUTH_GOOGLE_CLIENT_SECRET:-}
- LABLINK_OAUTH_GITHUB_CLIENT_ID=${LABLINK_OAUTH_GITHUB_CLIENT_ID:-}
- LABLINK_OAUTH_GITHUB_CLIENT_SECRET=${LABLINK_OAUTH_GITHUB_CLIENT_SECRET:-}
# Equipment
- LABLINK_VISA_BACKEND=${LABLINK_VISA_BACKEND:-@py}
- LABLINK_ENABLE_AUTO_RECONNECT=true
- LABLINK_ENABLE_HEALTH_MONITORING=true
# Feature flags
- LABLINK_ENABLE_PROFILES=true
- LABLINK_ENABLE_SAFETY_LIMITS=true
- LABLINK_SAFE_STATE_ON_DISCONNECT=true
- LABLINK_ENABLE_EQUIPMENT_LOCKS=true
devices:
# USB device access for equipment
- /dev/bus/usb:/dev/bus/usb
# Privileged mode for USB/Serial access
privileged: ${LABLINK_PRIVILEGED:-true}
networks:
- lablink-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "5"
deploy:
resources:
limits:
cpus: '${LABLINK_CPU_LIMIT:-2}'
memory: ${LABLINK_MEM_LIMIT:-1G}
reservations:
cpus: '0.5'
memory: 256M
# Web Dashboard (nginx serving static files + reverse proxy)
lablink-web:
build:
context: .
dockerfile: docker/Dockerfile.web
container_name: lablink-web
image: lablink-web:${LABLINK_VERSION:-latest}
restart: unless-stopped
ports:
- "${LABLINK_WEB_PORT:-80}:80"
- "${LABLINK_WEB_SSL_PORT:-443}:443"
volumes:
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- lablink-ssl-certs:/etc/nginx/ssl:ro
networks:
- lablink-network
depends_on:
lablink-server:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
interval: 30s
timeout: 10s
retries: 3
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
# Redis (optional - for caching, rate limiting, and pub/sub)
redis:
image: redis:7-alpine
container_name: lablink-redis
restart: unless-stopped
ports:
- "127.0.0.1:6379:6379"
volumes:
- lablink-redis-data:/data
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
networks:
- lablink-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
profiles:
- full
- caching
# PostgreSQL (optional - for production database instead of SQLite)
postgres:
image: postgres:15-alpine
container_name: lablink-postgres
restart: unless-stopped
ports:
- "127.0.0.1:5432:5432"
environment:
- POSTGRES_DB=${POSTGRES_DB:-lablink}
- POSTGRES_USER=${POSTGRES_USER:-lablink}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_INITDB_ARGS=--encoding=UTF8 --lc-collate=C --lc-ctype=C
volumes:
- lablink-postgres-data:/var/lib/postgresql/data
- ./docker/postgres/init:/docker-entrypoint-initdb.d:ro
networks:
- lablink-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-lablink}"]
interval: 30s
timeout: 10s
retries: 3
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
profiles:
- full
- postgres
# Grafana (optional - for monitoring and metrics visualization)
grafana:
image: grafana/grafana:latest
container_name: lablink-grafana
restart: unless-stopped
ports:
- "${GRAFANA_PORT:-3000}:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
- GF_SERVER_ROOT_URL=${GRAFANA_ROOT_URL:-http://localhost:3000}
- GF_INSTALL_PLUGINS=redis-datasource
volumes:
- lablink-grafana-data:/var/lib/grafana
- ./docker/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./docker/grafana/datasources:/etc/grafana/provisioning/datasources:ro
networks:
- lablink-network
depends_on:
- lablink-server
profiles:
- monitoring
- full
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
# Prometheus (optional - for metrics collection)
prometheus:
image: prom/prometheus:latest
container_name: lablink-prometheus
restart: unless-stopped
ports:
- "127.0.0.1:9090:9090"
volumes:
- lablink-prometheus-data:/prometheus
- ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=30d'
networks:
- lablink-network
depends_on:
- lablink-server
profiles:
- monitoring
- full
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
networks:
lablink-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
volumes:
# Server data
lablink-data:
driver: local
lablink-logs:
driver: local
lablink-backups:
driver: local
lablink-states:
driver: local
lablink-ssl-certs:
driver: local
# Optional services
lablink-redis-data:
driver: local
lablink-postgres-data:
driver: local
lablink-grafana-data:
driver: local
lablink-prometheus-data:
driver: local