-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
93 lines (88 loc) · 2.14 KB
/
docker-compose.yml
File metadata and controls
93 lines (88 loc) · 2.14 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
services:
# MongoDB Database
mongodb:
image: mongo:7.0
container_name: notes-mongodb
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: password123
MONGO_INITDB_DATABASE: notes_db
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
networks:
- notes-network
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Notes API Application
notes-api:
build:
context: .
dockerfile: Dockerfile
container_name: notes-api
restart: unless-stopped
env_file:
- .env.production
environment:
NODE_ENV: production
PORT: 3000
MONGODB_URI: mongodb://admin:password123@mongodb:27017/notes_db?authSource=admin
JWT_SECRET: ${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
COOKIE_SECRET: ${COOKIE_SECRET:-your-super-secret-cookie-key-change-in-production}
ports:
- "3000:3000"
depends_on:
mongodb:
condition: service_healthy
networks:
- notes-network
volumes:
- ./logs:/app/logs
healthcheck:
test: ["CMD", "node", "healthcheck.js"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Redis for Session Storage (Optional)
redis:
image: redis:7-alpine
container_name: notes-redis
restart: unless-stopped
ports:
- "6379:6379"
networks:
- notes-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
# Nginx Reverse Proxy (Optional)
nginx:
image: nginx:alpine
container_name: notes-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./ssl:/etc/nginx/ssl:ro
depends_on:
- notes-api
networks:
- notes-network
volumes:
mongodb_data:
driver: local
networks:
notes-network:
driver: bridge