|
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+# Docker Containerization Guide
|
|
|
2
|
+
|
|
|
3
|
+Complete guide for running Market Data Service in Docker containers for both development and production environments.
|
|
|
4
|
+
|
|
|
5
|
+## Table of Contents
|
|
|
6
|
+
|
|
|
7
|
+- [Prerequisites](#prerequisites)
|
|
|
8
|
+- [Quick Start](#quick-start)
|
|
|
9
|
+- [Development Setup](#development-setup)
|
|
|
10
|
+- [Production Setup](#production-setup)
|
|
|
11
|
+- [Configuration](#configuration)
|
|
|
12
|
+- [Common Operations](#common-operations)
|
|
|
13
|
+- [Troubleshooting](#troubleshooting)
|
|
|
14
|
+- [Backup and Restore](#backup-and-restore)
|
|
|
15
|
+
|
|
|
16
|
+## Prerequisites
|
|
|
17
|
+
|
|
|
18
|
+- **Docker Desktop** (Mac/Windows) or **Docker Engine** (Linux)
|
|
|
19
|
+- **Docker Compose** v2.0+ (included with Docker Desktop)
|
|
|
20
|
+- **Git** (for cloning repository)
|
|
|
21
|
+
|
|
|
22
|
+No other dependencies required! Everything runs in containers.
|
|
|
23
|
+
|
|
|
24
|
+## Quick Start
|
|
|
25
|
+
|
|
|
26
|
+### Development Environment
|
|
|
27
|
+
|
|
|
28
|
+```bash
|
|
|
29
|
+# 1. Clone the repository
|
|
|
30
|
+git clone <repository-url>
|
|
|
31
|
+cd market-data-service
|
|
|
32
|
+
|
|
|
33
|
+# 2. Copy environment template
|
|
|
34
|
+cp .env.example .env
|
|
|
35
|
+
|
|
|
36
|
+# 3. Edit .env file with your settings (optional for development)
|
|
|
37
|
+# Default values work for local development
|
|
|
38
|
+
|
|
|
39
|
+# 4. Start all services
|
|
|
40
|
+docker-compose up -d
|
|
|
41
|
+
|
|
|
42
|
+# 5. Check service status
|
|
|
43
|
+docker-compose ps
|
|
|
44
|
+
|
|
|
45
|
+# 6. View logs
|
|
|
46
|
+docker-compose logs -f api
|
|
|
47
|
+```
|
|
|
48
|
+
|
|
|
49
|
+The API will be available at:
|
|
|
50
|
+- **HTTP**: http://localhost
|
|
|
51
|
+- **API Endpoints**: http://localhost/api/*
|
|
|
52
|
+- **Health Check**: http://localhost/health
|
|
|
53
|
+- **WebSocket**: ws://localhost/socket.io/
|
|
|
54
|
+
|
|
|
55
|
+### Production Environment
|
|
|
56
|
+
|
|
|
57
|
+```bash
|
|
|
58
|
+# 1. Set up environment variables
|
|
|
59
|
+cp .env.example .env
|
|
|
60
|
+# Edit .env with production values
|
|
|
61
|
+
|
|
|
62
|
+# 2. Set up SSL certificates (if using HTTPS)
|
|
|
63
|
+# Place certificates in ./ssl/certs/ and ./ssl/private/
|
|
|
64
|
+# Or update SSL_CERT_PATH and SSL_KEY_PATH in docker-compose.prod.yml
|
|
|
65
|
+
|
|
|
66
|
+# 3. Start production services
|
|
|
67
|
+docker-compose -f docker-compose.prod.yml up -d
|
|
|
68
|
+
|
|
|
69
|
+# 4. Check status
|
|
|
70
|
+docker-compose -f docker-compose.prod.yml ps
|
|
|
71
|
+```
|
|
|
72
|
+
|
|
|
73
|
+## Development Setup
|
|
|
74
|
+
|
|
|
75
|
+### Architecture
|
|
|
76
|
+
|
|
|
77
|
+The development environment consists of three services:
|
|
|
78
|
+
|
|
|
79
|
+1. **API Service** (`api`)
|
|
|
80
|
+ - Node.js/Express application
|
|
|
81
|
+ - Live code reload with volume mounts
|
|
|
82
|
+ - Runs on port 3000 (internal)
|
|
|
83
|
+ - Accessible via Nginx on port 80
|
|
|
84
|
+
|
|
|
85
|
+2. **Database Service** (`db`)
|
|
|
86
|
+ - PostgreSQL 15
|
|
|
87
|
+ - Exposed on port 5432 (for local tools)
|
|
|
88
|
+ - Data persisted in Docker volume
|
|
|
89
|
+
|
|
|
90
|
+3. **Nginx Service** (`nginx`)
|
|
|
91
|
+ - Reverse proxy
|
|
|
92
|
+ - WebSocket support for Socket.io
|
|
|
93
|
+ - Exposed on port 80
|
|
|
94
|
+
|
|
|
95
|
+### Starting Development Environment
|
|
|
96
|
+
|
|
|
97
|
+```bash
|
|
|
98
|
+# Start all services in detached mode
|
|
|
99
|
+docker-compose up -d
|
|
|
100
|
+
|
|
|
101
|
+# Start with logs visible
|
|
|
102
|
+docker-compose up
|
|
|
103
|
+
|
|
|
104
|
+# Rebuild containers after code changes
|
|
|
105
|
+docker-compose up -d --build
|
|
|
106
|
+```
|
|
|
107
|
+
|
|
|
108
|
+### Accessing Services
|
|
|
109
|
+
|
|
|
110
|
+- **API**: http://localhost
|
|
|
111
|
+- **Database**: localhost:5432
|
|
|
112
|
+- **API Direct**: http://localhost:3000 (if port mapping enabled)
|
|
|
113
|
+
|
|
|
114
|
+### Development Workflow
|
|
|
115
|
+
|
|
|
116
|
+1. **Make code changes** in `src/` directory
|
|
|
117
|
+2. **Changes are automatically reloaded** (nodemon watches for changes)
|
|
|
118
|
+3. **View logs**: `docker-compose logs -f api`
|
|
|
119
|
+4. **Restart service**: `docker-compose restart api`
|
|
|
120
|
+
|
|
|
121
|
+### Database Migrations
|
|
|
122
|
+
|
|
|
123
|
+Migrations run automatically on container startup. To run manually:
|
|
|
124
|
+
|
|
|
125
|
+```bash
|
|
|
126
|
+# Run migrations
|
|
|
127
|
+docker-compose exec api npx sequelize-cli db:migrate
|
|
|
128
|
+
|
|
|
129
|
+# Rollback last migration
|
|
|
130
|
+docker-compose exec api npx sequelize-cli db:migrate:undo
|
|
|
131
|
+
|
|
|
132
|
+# Check migration status
|
|
|
133
|
+docker-compose exec api npx sequelize-cli db:migrate:status
|
|
|
134
|
+```
|
|
|
135
|
+
|
|
|
136
|
+### Accessing Database
|
|
|
137
|
+
|
|
|
138
|
+```bash
|
|
|
139
|
+# Connect to PostgreSQL
|
|
|
140
|
+docker-compose exec db psql -U postgres -d financial_data
|
|
|
141
|
+
|
|
|
142
|
+# Run SQL commands
|
|
|
143
|
+docker-compose exec db psql -U postgres -d financial_data -c "SELECT * FROM symbols LIMIT 10;"
|
|
|
144
|
+
|
|
|
145
|
+# List tables
|
|
|
146
|
+docker-compose exec db psql -U postgres -d financial_data -c "\dt"
|
|
|
147
|
+```
|
|
|
148
|
+
|
|
|
149
|
+## Production Setup
|
|
|
150
|
+
|
|
|
151
|
+### Architecture
|
|
|
152
|
+
|
|
|
153
|
+Production environment uses optimized settings:
|
|
|
154
|
+
|
|
|
155
|
+- **No volume mounts** (code baked into image)
|
|
|
156
|
+- **Multi-stage builds** for smaller images
|
|
|
157
|
+- **Health checks** for all services
|
|
|
158
|
+- **SSL/TLS** support via Nginx
|
|
|
159
|
+- **Restart policies** for high availability
|
|
|
160
|
+
|
|
|
161
|
+### Prerequisites for Production
|
|
|
162
|
+
|
|
|
163
|
+1. **Environment Variables**
|
|
|
164
|
+ ```bash
|
|
|
165
|
+ # Set strong passwords and secrets
|
|
|
166
|
+ DB_PASSWORD=<strong_password>
|
|
|
167
|
+ JWT_SECRET=<strong_random_secret>
|
|
|
168
|
+ CORS_ORIGIN=https://your-domain.com
|
|
|
169
|
+ ```
|
|
|
170
|
+
|
|
|
171
|
+2. **SSL Certificates** (for HTTPS)
|
|
|
172
|
+ ```bash
|
|
|
173
|
+ # Option 1: Use Let's Encrypt (recommended)
|
|
|
174
|
+ # Certificates will be in /etc/letsencrypt/live/your-domain.com/
|
|
|
175
|
+
|
|
|
176
|
+ # Option 2: Place certificates manually
|
|
|
177
|
+ mkdir -p ssl/certs ssl/private
|
|
|
178
|
+ # Copy fullchain.pem to ssl/certs/
|
|
|
179
|
+ # Copy privkey.pem to ssl/private/
|
|
|
180
|
+ ```
|
|
|
181
|
+
|
|
|
182
|
+3. **Update Nginx Configuration**
|
|
|
183
|
+ - Edit `nginx/nginx.prod.conf`
|
|
|
184
|
+ - Update SSL certificate paths
|
|
|
185
|
+ - Update `server_name` if using domain names
|
|
|
186
|
+
|
|
|
187
|
+### Starting Production Environment
|
|
|
188
|
+
|
|
|
189
|
+```bash
|
|
|
190
|
+# Build production images
|
|
|
191
|
+docker-compose -f docker-compose.prod.yml build
|
|
|
192
|
+
|
|
|
193
|
+# Start services
|
|
|
194
|
+docker-compose -f docker-compose.prod.yml up -d
|
|
|
195
|
+
|
|
|
196
|
+# Check health status
|
|
|
197
|
+docker-compose -f docker-compose.prod.yml ps
|
|
|
198
|
+```
|
|
|
199
|
+
|
|
|
200
|
+### Production Features
|
|
|
201
|
+
|
|
|
202
|
+- **Automatic migrations** on startup
|
|
|
203
|
+- **Health checks** for service monitoring
|
|
|
204
|
+- **SSL/TLS** encryption
|
|
|
205
|
+- **Security headers** (HSTS, X-Frame-Options, etc.)
|
|
|
206
|
+- **Rate limiting** (configurable in nginx.prod.conf)
|
|
|
207
|
+- **Data persistence** via Docker volumes
|
|
|
208
|
+
|
|
|
209
|
+## Configuration
|
|
|
210
|
+
|
|
|
211
|
+### Environment Variables
|
|
|
212
|
+
|
|
|
213
|
+Key environment variables (see `.env.example` for complete list):
|
|
|
214
|
+
|
|
|
215
|
+| Variable | Description | Default |
|
|
|
216
|
+|----------|-------------|---------|
|
|
|
217
|
+| `DB_HOST` | Database host | `db` (Docker) or `localhost` |
|
|
|
218
|
+| `DB_PORT` | Database port | `5432` |
|
|
|
219
|
+| `DB_NAME` | Database name | `financial_data` |
|
|
|
220
|
+| `DB_USER` | Database user | `postgres` |
|
|
|
221
|
+| `DB_PASSWORD` | Database password | **Required** |
|
|
|
222
|
+| `PORT` | API port | `3000` |
|
|
|
223
|
+| `NODE_ENV` | Environment | `development` or `production` |
|
|
|
224
|
+| `CORS_ORIGIN` | Allowed origins | `*` |
|
|
|
225
|
+| `JWT_SECRET` | JWT secret key | **Required** |
|
|
|
226
|
+| `LOG_LEVEL` | Logging level | `debug` (dev) or `info` (prod) |
|
|
|
227
|
+
|
|
|
228
|
+### Nginx Configuration
|
|
|
229
|
+
|
|
|
230
|
+- **Development**: `nginx/nginx.conf` (HTTP only)
|
|
|
231
|
+- **Production**: `nginx/nginx.prod.conf` (HTTPS with SSL)
|
|
|
232
|
+
|
|
|
233
|
+Key features:
|
|
|
234
|
+- WebSocket proxy for Socket.io
|
|
|
235
|
+- API endpoint routing
|
|
|
236
|
+- Health check endpoint
|
|
|
237
|
+- Security headers (production)
|
|
|
238
|
+- Rate limiting (production)
|
|
|
239
|
+
|
|
|
240
|
+### Database Configuration
|
|
|
241
|
+
|
|
|
242
|
+Database is automatically initialized with:
|
|
|
243
|
+- Database: `financial_data`
|
|
|
244
|
+- User: `postgres` (or from `DB_USER`)
|
|
|
245
|
+- Migrations run on API container startup
|
|
|
246
|
+
|
|
|
247
|
+## Common Operations
|
|
|
248
|
+
|
|
|
249
|
+### Viewing Logs
|
|
|
250
|
+
|
|
|
251
|
+```bash
|
|
|
252
|
+# All services
|
|
|
253
|
+docker-compose logs -f
|
|
|
254
|
+
|
|
|
255
|
+# Specific service
|
|
|
256
|
+docker-compose logs -f api
|
|
|
257
|
+docker-compose logs -f db
|
|
|
258
|
+docker-compose logs -f nginx
|
|
|
259
|
+
|
|
|
260
|
+# Last 100 lines
|
|
|
261
|
+docker-compose logs --tail=100 api
|
|
|
262
|
+```
|
|
|
263
|
+
|
|
|
264
|
+### Restarting Services
|
|
|
265
|
+
|
|
|
266
|
+```bash
|
|
|
267
|
+# Restart all services
|
|
|
268
|
+docker-compose restart
|
|
|
269
|
+
|
|
|
270
|
+# Restart specific service
|
|
|
271
|
+docker-compose restart api
|
|
|
272
|
+
|
|
|
273
|
+# Stop all services
|
|
|
274
|
+docker-compose down
|
|
|
275
|
+
|
|
|
276
|
+# Stop and remove volumes (WARNING: deletes data)
|
|
|
277
|
+docker-compose down -v
|
|
|
278
|
+```
|
|
|
279
|
+
|
|
|
280
|
+### Accessing Containers
|
|
|
281
|
+
|
|
|
282
|
+```bash
|
|
|
283
|
+# Execute command in API container
|
|
|
284
|
+docker-compose exec api sh
|
|
|
285
|
+
|
|
|
286
|
+# Execute command in database container
|
|
|
287
|
+docker-compose exec db sh
|
|
|
288
|
+
|
|
|
289
|
+# Run Node.js commands
|
|
|
290
|
+docker-compose exec api node -v
|
|
|
291
|
+docker-compose exec api npm list
|
|
|
292
|
+```
|
|
|
293
|
+
|
|
|
294
|
+### Updating Application
|
|
|
295
|
+
|
|
|
296
|
+```bash
|
|
|
297
|
+# 1. Pull latest code
|
|
|
298
|
+git pull
|
|
|
299
|
+
|
|
|
300
|
+# 2. Rebuild containers
|
|
|
301
|
+docker-compose build
|
|
|
302
|
+
|
|
|
303
|
+# 3. Restart services (migrations run automatically)
|
|
|
304
|
+docker-compose up -d
|
|
|
305
|
+
|
|
|
306
|
+# Or for production
|
|
|
307
|
+docker-compose -f docker-compose.prod.yml build
|
|
|
308
|
+docker-compose -f docker-compose.prod.yml up -d
|
|
|
309
|
+```
|
|
|
310
|
+
|
|
|
311
|
+### Health Checks
|
|
|
312
|
+
|
|
|
313
|
+```bash
|
|
|
314
|
+# Check container health
|
|
|
315
|
+docker-compose ps
|
|
|
316
|
+
|
|
|
317
|
+# Test API health endpoint
|
|
|
318
|
+curl http://localhost/health
|
|
|
319
|
+
|
|
|
320
|
+# Test database connection
|
|
|
321
|
+docker-compose exec db pg_isready -U postgres
|
|
|
322
|
+```
|
|
|
323
|
+
|
|
|
324
|
+## Troubleshooting
|
|
|
325
|
+
|
|
|
326
|
+### Database Connection Issues
|
|
|
327
|
+
|
|
|
328
|
+**Problem**: API can't connect to database
|
|
|
329
|
+
|
|
|
330
|
+**Solutions**:
|
|
|
331
|
+```bash
|
|
|
332
|
+# Check database is running
|
|
|
333
|
+docker-compose ps db
|
|
|
334
|
+
|
|
|
335
|
+# Check database logs
|
|
|
336
|
+docker-compose logs db
|
|
|
337
|
+
|
|
|
338
|
+# Test database connection manually
|
|
|
339
|
+docker-compose exec db psql -U postgres -d financial_data
|
|
|
340
|
+
|
|
|
341
|
+# Verify environment variables
|
|
|
342
|
+docker-compose exec api env | grep DB_
|
|
|
343
|
+```
|
|
|
344
|
+
|
|
|
345
|
+### Migration Failures
|
|
|
346
|
+
|
|
|
347
|
+**Problem**: Migrations fail on startup
|
|
|
348
|
+
|
|
|
349
|
+**Solutions**:
|
|
|
350
|
+```bash
|
|
|
351
|
+# Check migration logs
|
|
|
352
|
+docker-compose logs api | grep -i migration
|
|
|
353
|
+
|
|
|
354
|
+# Run migrations manually
|
|
|
355
|
+docker-compose exec api npx sequelize-cli db:migrate
|
|
|
356
|
+
|
|
|
357
|
+# Check migration status
|
|
|
358
|
+docker-compose exec api npx sequelize-cli db:migrate:status
|
|
|
359
|
+```
|
|
|
360
|
+
|
|
|
361
|
+### WebSocket Connection Issues
|
|
|
362
|
+
|
|
|
363
|
+**Problem**: WebSocket connections fail through Nginx
|
|
|
364
|
+
|
|
|
365
|
+**Solutions**:
|
|
|
366
|
+1. Verify Nginx configuration includes WebSocket upgrade headers
|
|
|
367
|
+2. Check Nginx logs: `docker-compose logs nginx`
|
|
|
368
|
+3. Test direct connection: `ws://localhost:3000/socket.io/`
|
|
|
369
|
+4. Verify Socket.io transport is set to 'websocket' only
|
|
|
370
|
+
|
|
|
371
|
+### Port Conflicts
|
|
|
372
|
+
|
|
|
373
|
+**Problem**: Port already in use
|
|
|
374
|
+
|
|
|
375
|
+**Solutions**:
|
|
|
376
|
+```bash
|
|
|
377
|
+# Check what's using the port
|
|
|
378
|
+lsof -i :80
|
|
|
379
|
+lsof -i :5432
|
|
|
380
|
+
|
|
|
381
|
+# Change ports in docker-compose.yml
|
|
|
382
|
+# Update PORT and DB_PORT environment variables
|
|
|
383
|
+```
|
|
|
384
|
+
|
|
|
385
|
+### Container Won't Start
|
|
|
386
|
+
|
|
|
387
|
+**Problem**: Container exits immediately
|
|
|
388
|
+
|
|
|
389
|
+**Solutions**:
|
|
|
390
|
+```bash
|
|
|
391
|
+# Check exit code
|
|
|
392
|
+docker-compose ps
|
|
|
393
|
+
|
|
|
394
|
+# View detailed logs
|
|
|
395
|
+docker-compose logs api
|
|
|
396
|
+
|
|
|
397
|
+# Check container status
|
|
|
398
|
+docker ps -a
|
|
|
399
|
+
|
|
|
400
|
+# Try starting without detached mode
|
|
|
401
|
+docker-compose up api
|
|
|
402
|
+```
|
|
|
403
|
+
|
|
|
404
|
+### Permission Issues
|
|
|
405
|
+
|
|
|
406
|
+**Problem**: Permission denied errors
|
|
|
407
|
+
|
|
|
408
|
+**Solutions**:
|
|
|
409
|
+```bash
|
|
|
410
|
+# Fix script permissions
|
|
|
411
|
+chmod +x docker/*.sh
|
|
|
412
|
+
|
|
|
413
|
+# Check file ownership
|
|
|
414
|
+ls -la docker/
|
|
|
415
|
+
|
|
|
416
|
+# Rebuild containers
|
|
|
417
|
+docker-compose build --no-cache
|
|
|
418
|
+```
|
|
|
419
|
+
|
|
|
420
|
+## Backup and Restore
|
|
|
421
|
+
|
|
|
422
|
+### Database Backup
|
|
|
423
|
+
|
|
|
424
|
+```bash
|
|
|
425
|
+# Create backup
|
|
|
426
|
+docker-compose exec db pg_dump -U postgres financial_data > backup_$(date +%Y%m%d_%H%M%S).sql
|
|
|
427
|
+
|
|
|
428
|
+# Or using docker directly
|
|
|
429
|
+docker exec market-data-db pg_dump -U postgres financial_data > backup.sql
|
|
|
430
|
+```
|
|
|
431
|
+
|
|
|
432
|
+### Database Restore
|
|
|
433
|
+
|
|
|
434
|
+```bash
|
|
|
435
|
+# Restore from backup
|
|
|
436
|
+docker-compose exec -T db psql -U postgres financial_data < backup.sql
|
|
|
437
|
+
|
|
|
438
|
+# Or using docker directly
|
|
|
439
|
+docker exec -i market-data-db psql -U postgres financial_data < backup.sql
|
|
|
440
|
+```
|
|
|
441
|
+
|
|
|
442
|
+### Volume Backup
|
|
|
443
|
+
|
|
|
444
|
+```bash
|
|
|
445
|
+# Backup database volume
|
|
|
446
|
+docker run --rm -v market_data_db_data:/data -v $(pwd):/backup alpine tar czf /backup/db_backup.tar.gz /data
|
|
|
447
|
+
|
|
|
448
|
+# Restore database volume
|
|
|
449
|
+docker run --rm -v market_data_db_data:/data -v $(pwd):/backup alpine tar xzf /backup/db_backup.tar.gz -C /
|
|
|
450
|
+```
|
|
|
451
|
+
|
|
|
452
|
+### Automated Backups
|
|
|
453
|
+
|
|
|
454
|
+Create a cron job or scheduled task:
|
|
|
455
|
+
|
|
|
456
|
+```bash
|
|
|
457
|
+# Daily backup script
|
|
|
458
|
+#!/bin/bash
|
|
|
459
|
+BACKUP_DIR="./backups"
|
|
|
460
|
+DATE=$(date +%Y%m%d_%H%M%S)
|
|
|
461
|
+mkdir -p $BACKUP_DIR
|
|
|
462
|
+docker-compose exec -T db pg_dump -U postgres financial_data | gzip > $BACKUP_DIR/backup_$DATE.sql.gz
|
|
|
463
|
+# Keep only last 30 days
|
|
|
464
|
+find $BACKUP_DIR -name "backup_*.sql.gz" -mtime +30 -delete
|
|
|
465
|
+```
|
|
|
466
|
+
|
|
|
467
|
+## MT5 EA Integration
|
|
|
468
|
+
|
|
|
469
|
+### Development
|
|
|
470
|
+
|
|
|
471
|
+Update MT5 EA settings:
|
|
|
472
|
+- `ApiBaseUrl`: `http://localhost` or `http://localhost:3000`
|
|
|
473
|
+
|
|
|
474
|
+### Production
|
|
|
475
|
+
|
|
|
476
|
+Update MT5 EA settings:
|
|
|
477
|
+- `ApiBaseUrl`: `https://your-domain.com`
|
|
|
478
|
+- Ensure SSL certificate is valid
|
|
|
479
|
+- WebSocket connections use `wss://` protocol
|
|
|
480
|
+
|
|
|
481
|
+## Performance Tuning
|
|
|
482
|
+
|
|
|
483
|
+### Database Optimization
|
|
|
484
|
+
|
|
|
485
|
+```bash
|
|
|
486
|
+# Increase shared buffers (edit postgresql.conf in container)
|
|
|
487
|
+# Or use environment variables in docker-compose.yml
|
|
|
488
|
+```
|
|
|
489
|
+
|
|
|
490
|
+### Nginx Optimization
|
|
|
491
|
+
|
|
|
492
|
+- Adjust `worker_processes` in nginx.conf
|
|
|
493
|
+- Tune `worker_connections` based on expected load
|
|
|
494
|
+- Enable caching for static assets (if any)
|
|
|
495
|
+
|
|
|
496
|
+### Container Resources
|
|
|
497
|
+
|
|
|
498
|
+Limit resources in `docker-compose.prod.yml`:
|
|
|
499
|
+
|
|
|
500
|
+```yaml
|
|
|
501
|
+services:
|
|
|
502
|
+ api:
|
|
|
503
|
+ deploy:
|
|
|
504
|
+ resources:
|
|
|
505
|
+ limits:
|
|
|
506
|
+ cpus: '2'
|
|
|
507
|
+ memory: 2G
|
|
|
508
|
+ reservations:
|
|
|
509
|
+ cpus: '1'
|
|
|
510
|
+ memory: 1G
|
|
|
511
|
+```
|
|
|
512
|
+
|
|
|
513
|
+## Security Best Practices
|
|
|
514
|
+
|
|
|
515
|
+1. **Change Default Passwords**: Always set strong `DB_PASSWORD` and `JWT_SECRET`
|
|
|
516
|
+2. **Use HTTPS in Production**: Configure SSL certificates
|
|
|
517
|
+3. **Limit CORS Origins**: Set specific `CORS_ORIGIN` in production
|
|
|
518
|
+4. **Regular Updates**: Keep Docker images updated
|
|
|
519
|
+5. **Backup Regularly**: Automate database backups
|
|
|
520
|
+6. **Monitor Logs**: Set up log monitoring and alerting
|
|
|
521
|
+7. **Use Secrets**: Consider Docker secrets for sensitive data
|
|
|
522
|
+
|
|
|
523
|
+## Additional Resources
|
|
|
524
|
+
|
|
|
525
|
+- [Docker Documentation](https://docs.docker.com/)
|
|
|
526
|
+- [Docker Compose Documentation](https://docs.docker.com/compose/)
|
|
|
527
|
+- [PostgreSQL Docker Image](https://hub.docker.com/_/postgres)
|
|
|
528
|
+- [Nginx Documentation](https://nginx.org/en/docs/)
|
|
|
529
|
+
|
|
|
530
|
+## Support
|
|
|
531
|
+
|
|
|
532
|
+For issues or questions:
|
|
|
533
|
+1. Check logs: `docker-compose logs`
|
|
|
534
|
+2. Review this documentation
|
|
|
535
|
+3. Check GitHub issues
|
|
|
536
|
+4. Contact development team
|
|
|
537
|
+
|