-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcompose.yml
More file actions
265 lines (248 loc) · 6.72 KB
/
compose.yml
File metadata and controls
265 lines (248 loc) · 6.72 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
name: sj
services:
postgres:
image: postgres:15
container_name: postgres
environment:
POSTGRES_USER: senjun
POSTGRES_PASSWORD: some_password
POSTGRES_DB: senjun
ports:
- "5432:5432"
volumes:
- postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U senjun"]
interval: 5s
timeout: 5s
retries: 5
networks:
- senjun-network
init_postgres:
profiles: [init]
image: postgres:15
container_name: init_postgres
environment:
PGPASSWORD: some_password
networks:
- senjun-network
depends_on:
postgres:
condition: service_healthy
restart: no
command: >
sh -c "
psql -h postgres -U senjun -d postgres -tc \"SELECT 1 FROM pg_database WHERE datname = 'handyman'\" | grep -q 1 || psql -h postgres -U senjun -d postgres -c 'CREATE DATABASE handyman OWNER senjun';
psql -h postgres -U senjun -d postgres -tc \"SELECT 1 FROM pg_database WHERE datname = 'scene'\" | grep -q 1 || psql -h postgres -U senjun -d postgres -c 'CREATE DATABASE scene OWNER senjun';
echo 'Databases created successfully'
"
watchman_cpp:
build:
context: ./infra/watchman_cpp
dockerfile: Dockerfile
image: sj/watchman
container_name: watchman
ports:
- "9000:8000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./compose-configs/watchman_cpp/watchman_cpp_config.json:/app/watchman_cpp_config.json:ro
environment:
- DOCKER_HOST=unix:///var/run/docker.sock
networks:
- senjun-network
depends_on:
- postgres
# Необходимо для работы с Docker API
user: root
group_add:
- "${DOCKER_GID:-999}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/check", "-X", "POST", "-H", "Content-Type: application/json", "-d", "{}", "-o", "/dev/null", "-s"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
handyman:
build:
context: ./infra/handyman
dockerfile: Dockerfile
image: sj/handyman
container_name: handyman
ports:
- "9080:8080"
volumes:
- .:/data/courses:ro
environment:
- WATCHMAN_ADDR=http://watchman_cpp:8000
- POSTGRES_CONN_STR=postgresql://senjun:some_password@postgres:5432/handyman?sslmode=disable
networks:
- senjun-network
depends_on:
postgres:
condition: service_healthy
watchman_cpp:
condition: service_healthy
restart: unless-stopped
init_handyman_db:
profiles: [init]
build:
context: ./infra/handyman/etc/
dockerfile_inline: |
FROM python:latest
COPY scripts/requirements.txt /requirements.txt
RUN pip install -r requirements.txt
image: sj/init_handyman_db
# that service we try to
pull_policy: never
container_name: init_handyman_db
environment:
POSTGRES_USER: senjun
PGPASSWORD: some_password
POSTGRES_DB: handyman
restart: no
depends_on:
init_postgres:
condition: service_completed_successfully
networks:
- senjun-network
volumes:
- ./infra/handyman/etc:/init_tools
- ./:/data/courses
entrypoint:
- python
- /init_tools/scripts/init_db.py
- --postgres_conn
- postgresql://senjun:some_password@postgres:5432/handyman?sslmode=disable
- --courses_dir
- /data/courses
- /init_tools/postgres_migrations/
init_scene_db:
profiles: [init]
build:
context: ./infra/scene
dockerfile: Dockerfile
image: sj/scene
container_name: init_scene_db
volumes:
- ./compose-configs/scene/conf.json:/app/scene/conf.json:ro
environment:
- PYTHONUNBUFFERED=1
networks:
- senjun-network
depends_on:
init_postgres:
condition: service_completed_successfully
restart: no
entrypoint: ["/bin/sh", "-c"]
command:
- |
python3 manage.py migrate --noinput &&
python3 manage.py createcachetable &&
echo 'Scene DB initialized successfully'
scene:
build:
context: ./infra/scene
dockerfile: Dockerfile
image: sj/scene
pull_policy: never
container_name: scene
ports:
- "8001:80"
volumes:
- ./compose-configs/scene/conf.json:/app/scene/conf.json:ro
- .:/data/courses:ro
environment:
- PYTHONUNBUFFERED=1
- HANDYMAN_URL=http://handyman:8080/
- DJANGO_DEBUG=1
networks:
- senjun-network
depends_on:
postgres:
condition: service_healthy
handyman:
condition: service_started
watchman_cpp:
condition: service_healthy
entrypoint:
- /app/.venv/bin/python
- /app/scene/manage.py
- runserver
- 0.0.0.0:80
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/", "-o", "/dev/null", "-s"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
pgadmin:
image: dpage/pgadmin4:latest
environment:
PGADMIN_DEFAULT_EMAIL: admin@senjun.ru
PGADMIN_DEFAULT_PASSWORD: admin
volumes:
- ./compose-configs/pgadmin/servers.json:/pgadmin4/servers.json
- ./compose-configs/pgadmin/pgpass:/pgpass
ports:
- 10000:80
networks:
- senjun-network
# Образы для выполнения пользовательского кода в watchman_cpp
senjun_python_image:
profiles: [images]
build:
context: ../senjun-images/python
dockerfile: Dockerfile
image: senjun_python
pull_policy: never
container_name: senjun_python_builder
restart: no
command: "true"
senjun_cpp_image:
profiles: [images]
build:
context: ../senjun-images/cpp
dockerfile: Dockerfile
image: senjun_cpp
pull_policy: never
container_name: senjun_cpp_builder
restart: no
command: "true"
senjun_golang_image:
profiles: [images]
build:
context: ../senjun-images/golang
dockerfile: Dockerfile
image: senjun_golang
pull_policy: never
container_name: senjun_golang_builder
restart: no
command: "true"
senjun_rust_image:
profiles: [images]
build:
context: ../senjun-images/rust
dockerfile: Dockerfile
image: senjun_rust
pull_policy: never
container_name: senjun_rust_builder
restart: no
command: "true"
senjun_haskell_image:
profiles: [images]
build:
context: ../senjun-images/haskell
dockerfile: Dockerfile
image: senjun_haskell
pull_policy: never
container_name: senjun_haskell_builder
restart: no
command: "true"
volumes:
postgres:
networks:
senjun-network:
driver: bridge