-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
109 lines (102 loc) · 2.52 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
version: "3.8"
x-env: &api-url
API_SERVER: http://static:8000
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
ports:
- "3308:3306"
volumes:
# init database and table
- ./init_db.sql:/docker-entrypoint-initdb.d/init_db.sql
- ./mysql-data:/var/lib/mysql
networks:
- db
environment:
MYSQL_DATABASE: ai_english
MYSQL_ROOT_PASSWORD: abc124
redis:
image: redis
command: redis-server /usr/local/etc/redis/redis.conf
volumes:
- ./redis-cnf:/usr/local/etc/redis
- ./redis-data:/data
networks:
- redis
# uwsgi
api:
build: .
# https://docs.docker.com/compose/compose-file/compose-file-v3/#build
# build image name
image: server:taishan
volumes:
- ./app:/taishan/app
- ./static:/taishan/static
- ./app.py:/taishan/app.py
- ./uwsgi.ini:/etc/uwsgi/uwsgi.ini
networks:
- db
- api
depends_on:
- db
- redis
env_file: .env
environment:
UWSGI_SOCKET: 0.0.0.0:8000
# override .env
HOST: db
PORT: 3306
USER_NAME: root
PASSWORD: abc124
# static service and forward request to uwsgi
static:
image: nginx:alpine
volumes:
- ./nginx.conf:/etc/nginx/templates/default.conf.template
- ./static:/static
ports:
# port on 6000 can't use on Mac
# https://stackoverflow.com/questions/4313403/why-do-browsers-block-some-ports/22622633#22622633
- "8000:8000" # api
- "7000:7000" # static
- "80:80"
expose:
- "8000"
# determine the order of service startup
# https://docs.docker.com/compose/compose-file/#depends_on
depends_on:
- api
networks:
- api
- web
environment:
UWSGI_SOCKET: api:8000
SERVER_PORT: 8000
FILE_SERVER_PORT: 7000
# web app
web:
image: web:taishan
ports:
- "8090:80"
depends_on:
- static
networks:
- web
environment: *api-url
# web for admin
admin:
image: admin:taishan
ports:
- "9000:80"
depends_on:
- static
networks:
- web
environment: *api-url
networks:
db:
redis:
api:
web: