-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
162 lines (155 loc) · 5.36 KB
/
docker-compose.yml
File metadata and controls
162 lines (155 loc) · 5.36 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
# PrintMaster Docker Compose Example
#
# This example demonstrates running PrintMaster server and agent with TimescaleDB.
# The server reads database config from environment variables:
# - SERVER_DB_HOST, SERVER_DB_PORT, SERVER_DB_USER, SERVER_DB_PASS, SERVER_DB_NAME
# - Falls back to DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME if SERVER_DB_* not set
#
# Customize the following before deploying to production:
# - Database credentials and connection settings
# - Port mappings and expose settings
# - Volume mount paths and persistent storage
# - Resource limits and restart policies
# - Network configuration and isolation
#
# Usage:
# Build and start: docker compose up -d --build
# View logs: docker compose logs -f server
# Stop services: docker compose down
# Cleanup volumes: docker compose down -v
version: '3.8'
services:
# TimescaleDB - PostgreSQL with time-series superpowers
# TimescaleDB is 100% PostgreSQL compatible but adds:
# - Hypertables: auto-partitioned time-series tables for faster queries
# - Compression: up to 95% storage reduction for historical metrics
# - Continuous Aggregates: auto-maintained rollups (hourly/daily summaries)
# - Retention Policies: declarative data lifecycle management
#
# PrintMaster auto-detects TimescaleDB and enables these features automatically.
# Replace credentials and tune performance for production use.
db:
image: timescale/timescaledb:latest-pg15
# --- Plain PostgreSQL Alternative ---
# If you prefer standard PostgreSQL without time-series features, use:
# image: postgres:15-alpine
# You'll miss out on:
# - Automatic metrics compression (uses ~5x more disk space)
# - Faster time-range queries on large datasets
# - Auto-maintained hourly/daily aggregates
# - Declarative retention policies
# PrintMaster will fall back to manual aggregation which works fine
# but is less efficient for large fleets (1000+ devices).
restart: unless-stopped
container_name: printmaster-db
hostname: db
# Ensure TimescaleDB is preloaded (required for existing databases)
command: ["postgres", "-c", "shared_preload_libraries=timescaledb"]
environment:
# IMPORTANT: Change these credentials in production
POSTGRES_USER: printmaster
POSTGRES_PASSWORD: changeme
POSTGRES_DB: printmaster
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U printmaster"]
interval: 10s
timeout: 5s
retries: 5
# pgAdmin (Optional) - Web UI for database management
# Comment out this service if you don't need the admin panel.
pgadmin:
image: dpage/pgadmin4:latest
restart: unless-stopped
container_name: printmaster-pgadmin
environment:
# IMPORTANT: Change these credentials in production
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: changeme
ports:
- "5050:80"
depends_on:
- db
# PrintMaster Server
# Central hub for multi-agent management and device aggregation.
server:
build:
context: .
dockerfile: server/Dockerfile
args:
VERSION: latest
restart: unless-stopped
container_name: printmaster-server
depends_on:
db:
condition: service_healthy
environment:
# Database configuration - use individual components instead of URL
DB_HOST: "db"
DB_PORT: "5432"
DB_NAME: "printmaster"
DB_USER: "printmaster"
DB_PASS: "changeme"
DOCKER: "true"
# Auto-join secret for agent registration (change to re-enable auto-join)
INIT_SECRET: "changeme-for-production"
# Uncomment and adjust additional server settings as needed:
# LOG_LEVEL: "info"
# TLS_CERT: "/var/lib/printmaster/server/cert.pem"
# TLS_KEY: "/var/lib/printmaster/server/key.pem"
ports:
- "9090:9090" # HTTP API
- "9443:9443" # HTTPS API
volumes:
# Persistent storage for logs, certificates, and data
- server-data:/var/lib/printmaster/server
networks:
- printmaster-net
# PrintMaster Agent (Optional)
# Local agent for printer discovery and monitoring. Can be run on separate hosts.
# Comment out if you only need the server.
agent:
build:
context: .
dockerfile: agent/Dockerfile
args:
VERSION: latest
restart: unless-stopped
container_name: printmaster-agent
depends_on:
- server
environment:
# Server registration
SERVER_URL: "http://server:9090"
DOCKER: "true"
# Auto-join secret (must match server INIT_SECRET for auto-registration)
INIT_SECRET: "changeme-for-production"
# Uncomment and adjust additional agent settings as needed:
# DISCOVERY_RANGE: "192.168.1.0/24"
# AGENT_NAME: "Site-A-Agent"
# LOG_LEVEL: "info"
ports:
- "8080:8080" # Web UI HTTP
- "8443:8443" # Web UI HTTPS
volumes:
# Persistent storage for discovered devices and metrics
- agent-data:/var/lib/printmaster/agent
networks:
- printmaster-net
volumes:
db-data:
name: printmaster_db_data
driver: local
server-data:
name: printmaster_server_data
driver: local
agent-data:
name: printmaster_agent_data
driver: local
networks:
printmaster-net:
name: printmaster-net
driver: bridge