-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yaml
50 lines (43 loc) · 1.17 KB
/
docker-compose.yaml
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
version: "3.9"
services:
mysql:
image: mysql
volumes:
# initialize db (tables creating)
- ./database_initialization/sql:/docker-entrypoint-initdb.d
# volume for persist data saving
- db_volume:/var/lib/mysql
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_USER=$DB_USER
- MYSQL_PASSWORD=$DB_PASSWORD
- MYSQL_DATABASE=$DB_NAME
command: --port $DB_PORT
redis:
image: redis
command: --port $REDIS_PORT
web:
# image: maxzhenzhera/async_blog_aiohttp
build: .
# to embed prepared .env
env_file:
- .env
# to override some connections vars (db - powered by docker)
environment:
DB_HOST: mysql
REDIS_HOST: redis
# for correct work [port exposing] in docker container
SERVER_HOST: 0.0.0.0
ports:
- 5000:$SERVER_PORT
depends_on:
- mysql
- redis
# on first startup db takes time for initializing
# any healthcheck is not used for this
# so, to ensure final start of the web service
# -> restart service always
# (obviously, on first time it`ll be errors about db connecting)
restart: always
volumes:
db_volume: