-
Notifications
You must be signed in to change notification settings - Fork 9
/
docker-compose.yml
94 lines (87 loc) · 2.92 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
version: '3'
services:
db:
container_name: postgres
image: postgres:9.5
environment:
# 超级用户 postgres 初始启动密码
PASTGRES_PASSWORD: password4superuser
ports:
- "5432:5432"
volumes:
# 把 db 的 data 映射出来,这样以后 image 任何时候启动数据都在
- ~/docker_volume/pg9.5:/var/lib/postgresql/data
app:
container_name: app
build:
# context 是 Dockerfile 的根目录,这里就是 docker-compose.yml 所在的目录
# 注意:值是个 点
context: .
dockerfile: Dockerfile_server
image:
naivegenerator-app:local
restart: always
ports:
- "8000:8000"
volumes:
# 项目目录映射
#!!!==== 测试正式环境时记得注释掉 ====#
# - ./demo_backend:/demo-backend # uncomment when develop. can not use with supervisord.conf(prod), only local
# 日志目录映射
- ~/docker_volume/log/celery:/var/log/celery
- ~/docker_volume/log/uwsgi:/var/log/uwsgi
# django 可以生成静态文件,共享到前端访问
# 需要输出到本地时,可以将这个注释掉
- app_static:/demo-backend/static
env_file:
- backend.local.env
# 本地需要,正式环境不需要,Dockerfile 中已经运行
# 此 command 会替换 Dockerfile 中的 supervisord.conf
#!!!==== 测试正式环境时记得注释掉 ====#
# command: supervisord.local.conf # comment to use supervisord.conf
depends_on:
- db
- redis
web:
container_name: web
build:
context: .
dockerfile: Dockerfile_local
image:
naivegenerator-web:local
restart: always
ports:
- "3000:3000"
volumes:
- ./demo_frontend:/demo-frontend
env_file:
- frontend.local.env
command: npm start
depends_on:
- app
nginx:
container_name: nginx
build:
context: .
dockerfile: Dockerfile_nginx
#!!!==== 正式部署 build 时记得注释掉 ====#
args:
backend_host: 192.168.65.2:8000 # in prod we need to use 127; local use 192.168.65.2
image:
naivegenerator-nginx:local # modify tag `local` to vx.x.x when build prod image
restart: always
ports:
- "443:443"
volumes:
- ~/docker_volume/log/nginx:/var/log/nginx
# 后端给共享的静态文件
- app_static:/demo-backend/static
depends_on:
- app
redis:
container_name: redis
image: redis:5.0.3-alpine
ports:
- "6379:6379"
volumes:
app_static: