-
Notifications
You must be signed in to change notification settings - Fork 143
/
docker-compose.yml
131 lines (118 loc) · 3.25 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
version: '3.8'
x-env-db: &env_db
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_HOST: ${MYSQL_HOST:-db}
MYSQL_PORT: ${MYSQL_PORT:-3306}
x-env-mq: &env_mq
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
MQ_PORT: ${MQ_PORT}
MQ_HOST: ${MQ_HOST:-mq}
MQ_ADMIN_PORT: ${MQ_ADMIN_PORT}
MQ_VHOST: ${MQ_VHOST:-/}
x-env-celery: &env_celery
SERVER_IP: ${SERVER_IP}
DJANGO_API_PORT: ${DJANGO_API_PORT}
x-env-app: &env_app
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_PORT: ${EMAIL_PORT}
EMAIL_HOST_USER: ${EMAIL_HOST_USER}
EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD}
LOKI_USERNAME: ${LOKI_USERNAME}
LOKI_PASSWORD: ${LOKI_PASSWORD}
LOKI_URL: ${LOKI_URL}
services:
db:
#image: mysql:8.0.21
image: mariadb:10.6.1
# privileged: true
environment:
# 设置默认数据库和root默认密码,如果宿主机中/var/lib/mysql已经存在,这两个设置都不会生效
<<: *env_db
volumes:
# - "/var/lib/mysql:/var/lib/mysql" # 挂载宿主机的mysql数据到docker中
- ./db/my.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
- ./db:/docker-entrypoint-initdb.d/:ro
# 端口映射,格式 宿主机端口:容器端口
ports:
- "${MYSQL_PORT_OUT}:3306"
restart: always
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
app:
image: fasterrunner_app:latest
build:
context: .
dockerfile: Dockerfile
args:
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}
DEBIAN_REPO: ${DEBIAN_REPO:-mirrors.aliyun.com}
environment:
<<: [*env_db, *env_celery, *env_app, *env_mq]
entrypoint: /app/start.sh
command: "app"
depends_on:
- db
restart: always
celery-worker:
build:
context: .
dockerfile: Dockerfile
args:
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}
DEBIAN_REPO: ${DEBIAN_REPO:-mirrors.aliyun.com}
environment:
<<: [*env_db, *env_celery, *env_app, *env_mq]
entrypoint: /app/start.sh
command: "celery-worker"
restart: always
depends_on:
- db
- mq
celery-beat:
build:
context: .
dockerfile: Dockerfile
args:
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}
DEBIAN_REPO: ${DEBIAN_REPO:-mirrors.aliyun.com}
environment:
<<: [*env_db, *env_celery, *env_app, *env_mq]
entrypoint: /app/start.sh
command: "celery-beat"
restart: always
depends_on:
- mq
- db
# django-admin & app proxy
nginx:
build: ./nginx
ports:
- "${DJANGO_ADMIN_PORT}:8000"
depends_on:
- app
restart: always
environment:
<<: [*env_db, *env_celery, *env_app, *env_mq]
web:
build:
context: ./web
dockerfile: Dockerfile
ports:
- "${WEB_PORT}:80"
volumes:
- ./web/dist:/usr/share/nginx/html
environment:
- FasterRunner=${MYSQL_USER}
depends_on:
- app
mq:
image: rabbitmq:management-alpine
environment:
<<: *env_mq
restart: always
ports:
- "${MQ_ADMIN_PORT}:15672"
- "${MQ_PORT}:5672"