-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
207 lines (191 loc) · 4.58 KB
/
docker-compose.yml
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
version: "3.9"
networks:
default:
name: $NETWORK_NAME
services:
postgres:
env_file:
- .env
image: postgres:13.3
user: $POSTGRES_USER:$POSTGRES_GROUP
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 5s
timeout: 3s
retries: 5
postgres-setup:
env_file:
- .env
environment:
- PGPASSWORD=$POSTGRES_PASSWORD
image: postgres:13.3
depends_on:
postgres:
condition: service_healthy
restart: "no"
entrypoint: ["psql", "-h", "postgres",
"-U", $POSTGRES_USER, "-d", $POSTGRES_DB,
"-c","CREATE SCHEMA IF NOT EXISTS content"
]
app:
env_file:
- .env
environment:
- DB_HOST=postgres
- DB_USER=$POSTGRES_USER
- DB_NAME=$POSTGRES_DB
- DB_PASSWORD=$POSTGRES_PASSWORD
depends_on:
postgres-setup:
condition: service_completed_successfully
image: yp_app
build:
context: ./app/
dockerfile: Dockerfile
volumes:
- ./app/static:/app/static:rw
healthcheck:
test: curl -sS http://127.0.0.1:8000 || exit 1
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
postgres-app-data-restore:
env_file:
- .env
environment:
- PGPASSWORD=$POSTGRES_PASSWORD
image: postgres:13.3
depends_on:
app:
condition: service_healthy
restart: "no"
volumes:
- ./app/app.data.sql:/app.data.sql
entrypoint: ["psql", "-h", "postgres",
"-U", $POSTGRES_USER, "-d", $POSTGRES_DB,
"-f","/app.data.sql"
]
app-web:
env_file:
- .env
image: nginx:latest
depends_on:
postgres-app-data-restore:
condition: service_completed_successfully
volumes:
- ./app/nginx.conf:/etc/nginx/nginx.conf
- ./app/static:/static:ro
ports:
- 9000:8000
redis:
env_file:
- .env
image: bitnami/redis:latest # поддерживает env REDIS_PASSWORD
depends_on:
app:
condition: service_healthy
app-web:
condition: service_started
healthcheck:
test: redis-cli -a $REDIS_PASSWORD ping || exit 1
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
ports:
- 6379:6379
elasticsearch:
env_file:
- .env
environment:
- discovery.type=single-node
- quiet=true
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
ports:
- 9200:9200
depends_on:
redis:
condition: service_healthy
healthcheck:
test: curl -sS -X GET "http://127.0.0.1:9200/_cluster/health?wait_for_status=green&timeout=10s" || exit 1
interval: 15s
timeout: 5s
retries: 5
start_period: 20s
elasticsearch-index-schema:
env_file:
- .env
image: appropriate/curl
depends_on:
elasticsearch:
condition: service_healthy
restart: "no"
volumes:
- ./etl/es_index.sh:/es_index.sh
entrypoint: /bin/sh /es_index.sh
etl:
env_file:
- .env
environment:
- DB_HOST=postgres
- DB_USER=$POSTGRES_USER
- DB_NAME=$POSTGRES_DB
- DB_PASSWORD=$POSTGRES_PASSWORD
image: python:3.9.12-slim-buster
depends_on:
elasticsearch-index-schema:
condition: service_completed_successfully
volumes:
- ./etl/:/etl/
- ./etl/requirements.txt:/requirements.txt
entrypoint: >
/bin/bash -c "
pip3 install -r /requirements.txt 2>/dev/null 1>/dev/null &&
cd /etl/ &&
python3 etl.py
"
check-etl-initial-load:
env_file:
- .env
image: appropriate/curl
depends_on:
etl:
condition: service_started
restart: "no"
volumes:
- ./etl/etl_check_initial_load.sh:/etl_check_initial_load.sh
entrypoint: /bin/sh /etl_check_initial_load.sh
api:
env_file:
- .env
depends_on:
redis:
condition: service_healthy
elasticsearch:
condition: service_healthy
elasticsearch-index-schema:
condition: service_completed_successfully
check-etl-initial-load:
condition: service_completed_successfully
image: yp_api
build:
context: ./api/
dockerfile: Dockerfile
healthcheck:
test: curl -sS http://127.0.0.1:8000/api/openapi || exit 1
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
api-web:
env_file:
- .env
image: nginx:latest
depends_on:
api:
condition: service_healthy
volumes:
- ./api/nginx.conf:/etc/nginx/nginx.conf
ports:
- 8000:8000