OnyxMunk/AudioForge
0
1# ============================================
2# AudioForge - Production Docker Compose
3# ============================================
4# Complete orchestration for all services
5# Includes monitoring, health checks, and scaling
6
7services:
8 # ============================================
9 # Database Layer
10 # ============================================
11 postgres:
12 image: postgres:16-alpine
13 container_name: audioforge-postgres
14 restart: unless-stopped
15 environment:
16 POSTGRES_USER: postgres
17 POSTGRES_PASSWORD: postgres
18 POSTGRES_DB: audioforge
19 POSTGRES_INITDB_ARGS: "-E UTF8 --locale=en_US.utf8"
20 PGDATA: /var/lib/postgresql/data/pgdata
21 ports:
22 - "5433:5432"
23 volumes:
24 - postgres_data:/var/lib/postgresql/data
25 healthcheck:
26 test: ["CMD-SHELL", "pg_isready -U postgres -d audioforge"]
27 interval: 10s
28 timeout: 5s
29 retries: 5
30 start_period: 10s
31 networks:
32 - audioforge-network
33 labels:
34 com.audioforge.service: "database"
35 com.audioforge.description: "PostgreSQL Database"
36
37 # ============================================
38 # Cache Layer
39 # ============================================
40 redis:
41 image: redis:7-alpine
42 container_name: audioforge-redis
43 restart: unless-stopped
44 command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
45 ports:
46 - "6379:6379"
47 volumes:
48 - redis_data:/data
49 healthcheck:
50 test: ["CMD", "redis-cli", "ping"]
51 interval: 10s
52 timeout: 5s
53 retries: 5
54 start_period: 5s
55 networks:
56 - audioforge-network
57 labels:
58 com.audioforge.service: "cache"
59 com.audioforge.description: "Redis Cache"
60
61 # ============================================
62 # Backend API
63 # ============================================
64 backend:
65 build:
66 context: ./backend
67 dockerfile: Dockerfile
68 target: runtime
69 container_name: audioforge-backend
70 restart: unless-stopped
71 ports:
72 - "8001:8000"
73 environment:
74 # Database
75 DATABASE_URL: postgresql+asyncpg://postgres:postgres@postgres:5432/audioforge
76 # Cache
77 REDIS_URL: redis://redis:6379/0
78 # ML Settings
79 MUSICGEN_DEVICE: cpu
80 BARK_DEVICE: cpu
81 # Application
82 LOG_LEVEL: info
83 ENVIRONMENT: production
84 NUMBA_CACHE_DIR: /tmp/numba_cache
85 # Security
86 ALLOWED_ORIGINS: "http://localhost:3000,http://frontend:3000"
87 volumes:
88 - audio_storage:/app/storage
89 - model_cache:/root/.cache
90 depends_on:
91 postgres:
92 condition: service_healthy
93 redis:
94 condition: service_healthy
95 healthcheck:
96 test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
97 interval: 30s
98 timeout: 10s
99 retries: 3
100 start_period: 40s
101 networks:
102 - audioforge-network
103 labels:
104 com.audioforge.service: "backend"
105 com.audioforge.description: "FastAPI Backend API"
106 deploy:
107 resources:
108 limits:
109 cpus: '2'
110 memory: 4G
111 reservations:
112 cpus: '1'
113 memory: 2G
114
115 # ============================================
116 # Frontend Application
117 # ============================================
118 frontend:
119 build:
120 context: ./frontend
121 dockerfile: Dockerfile
122 target: runner
123 container_name: audioforge-frontend
124 restart: unless-stopped
125 ports:
126 - "3000:3000"
127 environment:
128 NEXT_PUBLIC_API_URL: http://localhost:8001
129 API_URL: http://backend:8000
130 NODE_ENV: production
131 depends_on:
132 backend:
133 condition: service_healthy
134 healthcheck:
135 test: ["CMD", "curl", "-f", "http://localhost:3000/"]
136 interval: 30s
137 timeout: 10s
138 retries: 3
139 start_period: 40s
140 networks:
141 - audioforge-network
142 labels:
143 com.audioforge.service: "frontend"
144 com.audioforge.description: "Next.js Frontend"
145 deploy:
146 resources:
147 limits:
148 cpus: '1'
149 memory: 1G
150 reservations:
151 cpus: '0.5'
152 memory: 512M
153
154# ============================================
155# Networks
156# ============================================
157networks:
158 audioforge-network:
159 driver: bridge
160 name: audioforge-network
161 labels:
162 com.audioforge.network: "main"
163
164# ============================================
165# Volumes
166# ============================================
167volumes:
168 postgres_data:
169 driver: local
170 name: audioforge-postgres-data
171 labels:
172 com.audioforge.volume: "database"
173
174 redis_data:
175 driver: local
176 name: audioforge-redis-data
177 labels:
178 com.audioforge.volume: "cache"
179
180 audio_storage:
181 driver: local
182 name: audioforge-audio-storage
183 labels:
184 com.audioforge.volume: "audio"
185
186 model_cache:
187 driver: local
188 name: audioforge-model-cache
189 labels:
190 com.audioforge.volume: "models"
191 