generated from RealDevSquad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
115 lines (110 loc) · 2.67 KB
/
docker-compose.yml
File metadata and controls
115 lines (110 loc) · 2.67 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
services:
django-app:
build: .
container_name: todo-django-app
command: >
sh -c "
python manage.py migrate --noinput &&
python -Xfrozen_modules=off manage.py runserver_debug 0.0.0.0:8000 --debug-port 5678
"
environment:
MONGODB_URI: mongodb://db:27017/?replicaSet=rs0
DB_NAME: todo-app
PYTHONUNBUFFERED: 1
PYDEVD_DISABLE_FILE_VALIDATION: 1
# PostgreSQL Configuration
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_DB: todo_postgres
POSTGRES_USER: todo_user
POSTGRES_PASSWORD: todo_password
volumes:
- .:/app
ports:
- "8000:8000"
- "5678:5678" # Debug port
depends_on:
db:
condition: service_started
mongo-init:
condition: service_completed_successfully
postgres:
condition: service_healthy
stdin_open: true
tty: true
postgres:
image: postgres:17.6
container_name: todo-postgres
environment:
POSTGRES_DB: todo_postgres
POSTGRES_USER: todo_user
POSTGRES_PASSWORD: todo_password
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}",
]
interval: 10s
timeout: 5s
retries: 5
db:
image: mongo:latest
command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017", "--quiet"]
container_name: todo-mongo
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
healthcheck:
test:
[
"CMD",
"mongosh",
"--quiet",
"--eval",
"if (db.runCommand({ping:1}).ok) process.exit(0); else process.exit(1)",
]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
# Initialize replica set - this runs once and exits
mongo-init:
image: mongo:latest
depends_on:
db:
condition: service_healthy
command: >
mongosh --host db:27017 --eval "
try {
rs.status();
print('Replica set already initialized');
} catch(e) {
print('Initializing replica set...');
rs.initiate({
_id: 'rs0',
members: [{ _id: 0, host: 'db:27017' }]
});
print('Replica set initialized');
}
"
restart: "no"
mongo-express:
image: mongo-express
container_name: todo-mongo-express
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_URL: mongodb://db:27017/
ME_CONFIG_BASICAUTH: false
depends_on:
- db
- mongo-init
volumes:
postgres_data:
mongo_data: