forked from Newer1107/tux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
284 lines (265 loc) · 10.8 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
284 lines (265 loc) · 10.8 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
# ==============================================================================
# SERVICES CONFIGURATION - DEVELOPMENT ENVIRONMENT
# ==============================================================================
services:
# ============================================================================
# TUX BOT SERVICE - Development Container
# ============================================================================
# Purpose: Runs the Tux Discord bot in development mode with live reloading
# Features: Code synchronization, automatic rebuilds, development tools
# Performance: Higher resource limits for development workloads
# ============================================================================
tux:
# CONTAINER IDENTIFICATION
# Development-specific name to avoid conflicts with production containers
# Clearly identifies this as a development instance
container_name: tux-dev
# IMAGE CONFIGURATION
# Uses local development image built from dev stage of Dockerfile
# Contains development tools, debugging utilities, and additional packages
image: tux:dev
# BUILD CONFIGURATION
# Always builds from local source for development
# Uses development target with full tooling and debugging capabilities
build:
# Build context includes entire project directory
context: .
# Dockerfile location (standard)
dockerfile: Dockerfile
# Target development stage with debugging tools and dev dependencies
target: dev
# DEVELOPMENT OVERRIDE COMMAND
# Skip prisma generate in CMD to avoid read-only filesystem issues
# Can be run manually after container starts
command:
- sh
- -c
- exec poetry run tux --dev start
# DEVELOPMENT WORKFLOW CONFIGURATION
# Docker BuildKit watch feature for live development
# Provides real-time code synchronization and intelligent rebuilds
develop:
# WATCH CONFIGURATION
# Monitors filesystem changes and syncs/rebuilds as appropriate
# Optimizes development workflow with minimal container restarts
watch:
# FILE SYNCHRONIZATION (Hot Reload)
# Syncs code changes without rebuilding the container
# Fastest feedback loop for code changes
- action: sync
# Watch entire project directory
path: .
# Sync to app directory in container
target: /app/
# IGNORE PATTERNS
# Excludes files that don't need syncing or would cause issues
# Performance optimization to reduce sync overhead
ignore:
# Cache directories (not needed in sync)
- .cache/
# IDE configurations (not needed in container)
- .idea/
# Virtual environment (managed by container)
- .venv/
# Editor configurations (not needed in container)
- .vscode/
# Python cache files (regenerated automatically)
- '**/__pycache__/'
- '**/*.pyc'
# Log files (not needed in sync)
- '*.log'
# Editor temporary files
- '*.swp'
- .*.swp
- '*~'
# DEPENDENCY REBUILD TRIGGERS
# Files that require full container rebuild when changed
# These changes affect the environment setup and need fresh build
# Python dependencies changed - rebuild required
- action: rebuild
path: pyproject.toml
# Lock file updated - rebuild required for dependency consistency
- action: rebuild
path: poetry.lock
# Database schema changes - rebuild required for Prisma client generation
- action: rebuild
path: prisma/schema/
# VOLUME MOUNTS
# Development-specific volumes with different naming to avoid production conflicts
# Focuses on persistence of development data without read-only restrictions
volumes:
# DEVELOPMENT CACHE VOLUME
# Separate cache volume for development to avoid conflicts with production
# Contains development-specific cache data and temporary files
- tux_dev_cache:/app/.cache
# DEVELOPMENT TEMPORARY VOLUME
# Separate temporary volume for development work
# Used for development artifacts, debugging files, etc.
- tux_dev_temp:/app/temp
# USER HOME VOLUME
# Single volume for all user cache/config directories (.cache, .npm, etc.)
# Prevents read-only filesystem errors and covers all CLI tools
- tux_dev_user_home:/home/nonroot
# ENVIRONMENT CONFIGURATION
# Environment variables loaded from .env file
# Same as production but may contain different values for development
# DEVELOPMENT: May include debug flags, development database URLs, etc.
env_file:
- .env
# RESTART POLICY
# Automatic restart for development convenience
# Helps maintain development environment during crashes and testing
restart: unless-stopped
# RESOURCE MANAGEMENT
# Higher resource limits for development workloads
# Development often requires more resources for compilation, debugging, etc.
deploy:
resources:
# RESOURCE LIMITS (Development)
# Higher limits to accommodate development tools and processes
limits:
memory: 1g # Maximum 1GB RAM (double production)
cpus: '1.0' # Maximum 1 full CPU core (double production)
# RESOURCE RESERVATIONS (Development)
# Higher reservations for better development performance
reservations:
memory: 512m # Guaranteed 512MB RAM (double production)
cpus: '0.5' # Guaranteed 0.5 CPU cores (double production)
# LOGGING CONFIGURATION
# Same logging setup as production for consistency
# Helps developers understand production logging behavior
logging:
# JSON structured logging for development log analysis
driver: json-file
# Log rotation to prevent development disk space issues
options:
max-size: 10m # Rotate logs when they reach 10MB
max-file: '3' # Keep maximum 3 rotated log files
# ==============================================================================
# VOLUMES CONFIGURATION - DEVELOPMENT ENVIRONMENT
# ==============================================================================
# Development-specific named volumes to avoid conflicts with production
# These volumes are isolated from production and can be safely removed
# for clean development environment resets
# ==============================================================================
volumes:
# DEVELOPMENT CACHE VOLUME
# Stores development-specific cache data
# Contains: Development API cache, debug cache, test data, etc.
# Isolation: Completely separate from production cache
# Lifecycle: Can be reset anytime for clean development environment
tux_dev_cache:
driver: local # Local Docker volume driver (default)
# DEVELOPMENT TEMPORARY VOLUME
# Stores development temporary files and artifacts
# Contains: Debug files, development logs, test artifacts, etc.
# Isolation: Separate from production temporary data
# Lifecycle: Safe to clear for clean development state
tux_dev_temp:
driver: local # Local Docker volume driver (default)
# DEVELOPMENT USER HOME VOLUME
# Stores all user cache and config directories
# Contains: .cache (Prisma), .npm, .config, and other CLI tool data
# Isolation: Separate from production user data
# Lifecycle: Persistent to avoid re-downloading tools and cache
tux_dev_user_home:
driver: local # Local Docker volume driver (default)
# ==============================================================================
# DEVELOPMENT WORKFLOW BEST PRACTICES IMPLEMENTED
# ==============================================================================
#
# 1. LIVE DEVELOPMENT:
# - Real-time code synchronization with Docker BuildKit watch
# - Intelligent rebuild triggers for dependency changes
# - Optimized ignore patterns for performance
# - Hot reload for rapid iteration
#
# 2. DEVELOPMENT ISOLATION:
# - Separate container name and volumes from production
# - Development-specific image with debugging tools
# - Isolated environment that doesn't affect production
#
# 3. RESOURCE OPTIMIZATION:
# - Higher resource limits for development workloads
# - Adequate resources for compilation and debugging
# - Performance optimized for development tasks
#
# 4. WORKFLOW EFFICIENCY:
# - Automatic restart for development convenience
# - Easy shell access for debugging and development
# - Consistent logging with production for familiarity
#
# 5. DEPENDENCY MANAGEMENT:
# - Automatic rebuilds on dependency file changes
# - Schema change detection for database updates
# - Smart rebuild triggers to minimize wait time
#
# DEVELOPMENT WORKFLOW:
# ---------------------
# 1. Start development environment:
# docker-compose -f docker-compose.dev.yml up
#
# 2. Edit code - changes sync automatically
# (No restart needed for code changes)
#
# 3. Update dependencies in pyproject.toml:
# (Container rebuilds automatically)
#
# 4. Debug with shell access:
# docker-compose -f docker-compose.dev.yml exec tux bash
#
# 5. View logs:
# docker-compose -f docker-compose.dev.yml logs -f tux
#
# 6. Clean restart:
# docker-compose -f docker-compose.dev.yml down
# docker-compose -f docker-compose.dev.yml up --build
#
# ==============================================================================
#
# TUX CLI COMMANDS (Recommended):
# --------------------------------
# Build: poetry run tux --dev docker build
# Start: poetry run tux --dev docker up [-d|--build]
# Logs: poetry run tux --dev docker logs -f
# Shell: poetry run tux --dev docker shell
# Stop: poetry run tux --dev docker down
#
# Development workflow (from host):
# poetry run tux --dev docker exec tux "tux dev lint"
# poetry run tux --dev docker exec tux "pytest"
#
# Database (from host):
# poetry run tux --dev docker exec tux "tux db push"
# poetry run tux --dev docker exec tux "tux db migrate --name <name>"
#
# DEVELOPMENT COMMANDS:
# ---------------------
# Start development:
# docker-compose -f docker-compose.dev.yml up
#
# Start in background:
# docker-compose -f docker-compose.dev.yml up -d
#
# Force rebuild:
# docker-compose -f docker-compose.dev.yml up --build
#
# Shell access:
# docker-compose -f docker-compose.dev.yml exec tux bash
#
# Run linting:
# docker-compose -f docker-compose.dev.yml exec tux poetry run tux dev lint
#
# Run tests:
# docker-compose -f docker-compose.dev.yml exec tux poetry run pytest
#
# Database operations:
# docker-compose -f docker-compose.dev.yml exec tux poetry run tux --dev db push
#
# Stop development:
# docker-compose -f docker-compose.dev.yml down
#
# Clean reset (removes volumes):
# docker-compose -f docker-compose.dev.yml down -v
#
# ==============================================================================