-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-compose.yml
231 lines (223 loc) · 6.57 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
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
services:
db:
build:
context: .
dockerfile: ./db_folder/Dockerfile
restart: unless-stopped
networks:
- custom_network
ports:
- 5432:5432
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
env_file:
- .env
user: root
volumes:
- ./db_folder/pg_12:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}"]
interval: 30s
timeout: 5s
retries: 5
webapi:
build:
context: .
dockerfile: ./webapi/Dockerfile
container_name: webapi
restart: unless-stopped
env_file:
- .env
volumes:
- api-dir:/fastapi
depends_on:
db:
condition: service_healthy
networks:
- custom_network
ports:
- 8004:8000
command: bash -c "/wait && uvicorn webapi.server:app --reload --workers 1 --host 0.0.0.0 --port 8000 --root-path /webapi"
#"while !</dev/tcp/db/5432; do sleep 1; done; alembic upgrade head && uvicorn webapi.server:app --reload --workers 1 --host 0.0.0.0 --port 8000"
environment:
- CONTAINER_NAME=api
- API_URL=http://webapi:8000
- WAIT_HOSTS=${POSTGRES_SERVER}:${POSTGRES_PORT}
- WAIT_TIMEOUT=300
- WAIT_SLEEP_INTERVAL=30
- WAIT_HOST_CONNECT_TIMEOUT=30
# - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_SERVER}:${POSTGRES_PORT}/${POSTGRES_DB}
healthcheck:
test: curl http://webapi:8000/healthcheck || exit 1
interval: 60s
timeout: 5s
retries: 5
start_period: 60s
labels:
- "traefik.enable=true"
- "traefik.http.routers.webapi.rule=Host(`${WEB_SERVER_NAME:-localhost}`) && PathPrefix(`/webapi`)"
- "traefik.http.services.webapi.loadbalancer.server.port=8000"
- "traefik.http.middlewares.webapi-strip.stripprefix.prefixes=/webapi"
- "traefik.http.routers.webapi.middlewares=webapi-strip@docker"
webapp:
build:
context: .
dockerfile: ./ui_new/Dockerfile
container_name: webapp
restart: unless-stopped
networks:
- custom_network
ports:
- 8181:8181
volumes:
- webapp-dir:/webapp
env_file:
- .env
healthcheck:
test: curl http://webapp:8181/healthcheck || exit 1
interval: 1m30s
timeout: 30s
retries: 5
start_period: 30s
environment:
- CONTAINER_NAME=webapp
- API_URL=http://webapi:8000
depends_on:
webapi:
condition: service_healthy
labels:
- "traefik.enable=true"
- "traefik.http.routers.webapp.rule=Host(`${WEB_SERVER_NAME:-localhost}`) && PathPrefix(`/webapp`)"
- "traefik.http.services.webapp.loadbalancer.server.port=8181"
- "traefik.http.middlewares.webapp-strip.stripprefix.prefixes=/webapp"
- "traefik.http.routers.webapp.middlewares=webapp-strip@docker"
3cxcdrserver:
build:
context: .
dockerfile: ./srv/Dockerfile
tty: true
networks:
- custom_network
ports:
- 5000:5000
env_file:
- .env
depends_on:
webapi:
condition: service_healthy
restart: unless-stopped
command: bash -c "/wait && python -m alembic upgrade head && python srv/runserver.py"
environment:
- API_URL=http://webapi:8000
- WAIT_HOSTS=${POSTGRES_SERVER}:${POSTGRES_PORT}
- WAIT_TIMEOUT=300
- WAIT_SLEEP_INTERVAL=30
- WAIT_HOST_CONNECT_TIMEOUT=30
# - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_SERVER}:${POSTGRES_PORT}/${POSTGRES_DB}
volumes:
- app-code:/home/appuser/app
#- ./srv/datas:/home/appuser/cdrfiles
- cdr_datas:/home/appuser/cdrfiles
- ${LOCAL_CDR_FOLDER_ARCHIVE}:/home/appuser/cdrfiles/cdrfiles_archives:rw
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
depends_on:
db:
condition: service_healthy
networks:
- custom_network
ports:
- 5555:80
env_file:
- .env
environment:
- CONTAINER_NAME = pgadmin
- PGADMIN_LISTEN_PORT=8006
- PGADMIN_DISABLE_POSTFIX=true
restart: unless-stopped
volumes:
- pgadmin_data:/var/lib/pgadmin/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.pgadmin.rule=Host(`${WEB_SERVER_NAME:-localhost}`) && PathPrefix(`/pgadmin`)"
- "traefik.http.services.pgadmin.loadbalancer.server.port=8006"
- "traefik.http.middlewares.pgadmin-strip.stripprefix.prefixes=/pgadmin"
- "traefik.http.middlewares.pgadmin-headers.headers.customRequestHeaders.X-Script-Name=/pgadmin"
- "traefik.http.middlewares.pgadmin-headers.headers.customRequestHeaders.X-Scheme=http"
- "traefik.http.routers.pgadmin.middlewares=pgadmin-strip@docker,pgadmin-headers@docker"
grafana:
image: grafana/grafana:latest
environment:
- CONTAINER_NAME=grafana
depends_on:
- db
networks:
- custom_network
ports:
- 3000:3000
restart: unless-stopped
env_file:
- .env
volumes:
- grafana-storage:/var/lib/grafana
- ./grafana/custom.ini:/etc/grafana/custom.ini
- ./grafana_init/provisioning/:/etc/grafana/provisioning/
- ./grafana_init/provisioning/dashboards/dashboard_files/:/var/lib/grafana/dashboards/
labels:
- "traefik.enable=true"
- "traefik.http.routers.grafana.rule=Host(`${WEB_SERVER_NAME:-localhost}`) && PathPrefix(`/grafana`)"
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
traefik:
image: traefik:v2.10
env_file:
- .env
ports:
- 80:80
- 8080:8080
depends_on:
webapp:
condition: service_started
environment:
- CONTAINER_NAME=traefik
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik/logs:/var/log/traefik
- ./traefik/traefik.toml:/etc/traefik/traefik.toml
networks:
- custom_network
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik-api.rule=Host(`${WEB_SERVER_NAME:-localhost}`)"
- "traefik.http.routers.traefik-api.service=api@internal"
volumes:
pgadmin_data:
grafana-storage:
cdr_datas:
app-code:
driver: local
driver_opts:
type: none
device: .
o: bind
api-dir:
driver: local
driver_opts:
type: none
device: .
o: bind
webapp-dir:
driver: local
driver_opts:
type: none
device: .
o: bind
networks:
custom_network:
driver: bridge
ipam:
config:
- subnet: ${DOCKER_SUBNET}
gateway: ${DOCKER_GATEWAY}