-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-compose.prod.yml
151 lines (143 loc) · 3.89 KB
/
docker-compose.prod.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
version: '3.3'
services:
web:
restart: always
build:
context: ./app
command: /src/venv/bin/gunicorn app.wsgi:application --bind 0.0.0.0:8000 --reload
entrypoint: '/home/app/web/entrypoint.sh'
volumes:
- ./app:/home/app/web
- static_volume:/home/app/web/staticfiles
- media_volume:/home/app/web/mediafiles
expose:
- 8000
env_file:
- ./.env.prod
depends_on:
- db
labels:
- "traefik.enable=true"
- "traefik.http.routers.django.rule=Host(`localhost`) && PathPrefix(`/backend`)" # Change `localhost` to `your.domain.com`
- "traefik.http.routers.django.tls=true"
- "traefik.http.routers.django.tls.certresolver=letsencrypt"
nginx:
build: ./nginx
volumes:
- static_volume:/home/app/web/staticfiles
- media_volume:/home/app/web/mediafiles
expose:
- 80
depends_on:
- web
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.rule=Host(`localhost`) && PathPrefix(`/staticfiles`, `/mediafiles`)" # Change `localhost`
- "traefik.http.routers.nginx.tls=true"
- "traefik.http.routers.nginx.tls.certresolver=letsencrypt"
db:
image: postgres:12.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env.prod.db
redis:
image: redis
restart: always
container_name: 'redis'
command: redis-server
working_dir: /data
volumes:
- redisdata:/data
- /etc/localtime:/etc/localtime
expose:
- 6379
celery:
build:
context: ./app
container_name: 'celery'
command: /src/venv/bin/celery -A app worker -B
env_file:
- ./.env.prod
volumes:
- .:/code
links:
- redis
depends_on:
- web
- redis
flower:
image: mher/flower
ports:
- 5555:5555
environment:
- CELERY_BROKER_API=redis://redis:6379/0
- CELERY_BROKER_URL=redis://redis:6379/0
depends_on:
- celery
daphne:
build:
context: ./app
command: /src/venv/bin/daphne -b 0.0.0.0 -p 8001 app.asgi:application
expose:
- 8001
volumes:
- ./app:/home/app/web
env_file:
- ./.env.prod
environment:
- REDIS_HOST=redis
depends_on:
- redis
- web
links:
- redis
labels:
- "traefik.enable=true"
- "traefik.http.routers.daphne.rule=Host(`localhost`) && PathPrefix(`/ws`)"
- "traefik.http.routers.daphne.tls=true"
- "traefik.http.routers.daphne.tls.certresolver=letsencrypt"
# Example how add React app
# frontend:
# container_name: frontend
# build: ./react-app
# volumes:
# - './react-app:/app'
# - '/app/node_modules'
# expose:
# - 3000
# stdin_open: true
# environment:
# - CHOKIDAR_USEPOLLING=true
# command: npm start
# labels: # new
# - "traefik.enable=true"
# - "traefik.http.routers.react.rule=Host(`localhost`)"
# - "traefik.http.routers.react.tls=true"
# - "traefik.http.routers.react.tls.certresolver=letsencrypt"
traefik:
image: traefik:v2.2
ports:
- 80:80
- 443:443
volumes:
- "./traefik.toml:/etc/traefik/traefik.toml"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik-public-certificates:/certificates"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`dashboard-traefik.localhost`)"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=testuser:$$apr1$$jIKW.bdS$$eKXe4Lxjgy/rH65wP1iQe1"
# login: testuser
# password: password
volumes:
postgres_data:
traefik-public-certificates:
static_volume:
media_volume:
redisdata:
driver: local