-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
176 lines (173 loc) · 5.02 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
version: "3.11"
services:
frontend:
build:
context: ./frontend
ports:
- "8080:8080"
volumes:
- "./frontend/src:/frontend/src"
- "./frontend/public:/frontend/public"
- "/src/node_modules"
environment:
- VUE_APP_BASE_API_URL=http://0.0.0.0:8000/
- VUE_APP_BASE_WS_URL=ws://0.0.0.0:8888/
depends_on:
- api
api:
build:
# path to directory containing Dockerfile
context: ./api
args:
# set DEV argument to true
- DEV=true
# map local port 8000 to port 8000 in container
ports:
- "8000:8000"
# map directory from system to docker container
volumes:
- "./api/src:/src"
# commands run from container
command: >
sh -c "
python manage.py wait_for_db &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000
"
# uncomment this if you don't want to define .env file
# environment:
# - DB_HOST=db
# - DB_NAME=devdb
# - DB_USER=devuser
# - DB_PASS=devpass
# - DATABASE_PORT=5432
# # redis env variables
# - REDIS_HOST=redis_db
# - REDIS_PORT=6379
# - REDIS_PASS=dev_redispass
# # celery env variables
# - CELERY_BROKER_URL=redis://:dev_redispass@redis_db:6379
# - CELERY_RESULT_BACKEND=redis://:dev_redispass@redis_db:6379
# # email settings
# - EMAIL_HOST_USER=YOUR_HOST
# - EMAIL_HOST_PASSWORD=YOUR_PWD
# # project settings
# - BASE_URL=http://someurl/
# - BASE_FRONTEND_URL="http://localhost:8080/"
# - DEBUG=True
# - ALLOWED_HOSTS="host1,host2"
# - SECRET_KEY=YOUR_SECRET_KEY
# - CORS_ORIGIN_WHITELIST="host1,host2"
# - CORS_ALLOWED_ORIGINS="host1,host2"
# - CSRF_TRUSTED_ORIGINS="host1,host2"
# - CODESPACE_REDIS_EXPIRE_TIME=1200
# - TMP_CODESPACE_REDIS_EXPIRE_TIME=1200
# wait till db service start
depends_on:
- db
- redis_db
# celery worker will execute async to take load from python api
celery_worker:
restart: always
build:
context: ./api
args:
# set DEV argument to true
- DEV=true
# map directory from system to docker container
volumes:
- "./api/src:/src"
command: celery -A src worker -l INFO
# uncomment this if you don't want to define .env file
# environment:
# - DB_HOST=db
# - DB_NAME=devdb
# - DB_USER=devuser
# - DB_PASS=devpass
# - DATABASE_PORT=5432
# # redis env variables
# - REDIS_HOST=redis_db
# - REDIS_PORT=6379
# - REDIS_PASS=dev_redispass
# # celery env variables
# - CELERY_BROKER_URL=redis://:dev_redispass@redis_db:6379
# - CELERY_RESULT_BACKEND=redis://:dev_redispass@redis_db:6379
# # email settings
# - EMAIL_HOST_USER=YOUR_HOST
# - EMAIL_HOST_PASSWORD=YOUR_PWD
# # project settings
# - BASE_URL=http://someurl/
# - BASE_FRONTEND_URL="http://localhost:8080/"
# - DEBUG=True
# - ALLOWED_HOSTS="host1,host2"
# - SECRET_KEY=YOUR_SECRET_KEY
# - CORS_ORIGIN_WHITELIST="host1,host2"
# - CORS_ALLOWED_ORIGINS="host1,host2"
# - CSRF_TRUSTED_ORIGINS="host1,host2"
# - CODESPACE_REDIS_EXPIRE_TIME=1200
# - TMP_CODESPACE_REDIS_EXPIRE_TIME=1200
depends_on:
- db
- redis_db
- api
websocket_server:
build:
# path to directory containing Dockerfile
context: ./websocket_server
args:
# set DEV argument to true
- DEV=true
# map directory from system to docker container
volumes:
- "./websocket_server/src:/src"
# commands run from container
command: watchmedo auto-restart --pattern "*.py" --recursive --signal SIGTERM -- sanic main.app --host 0.0.0.0 --port 8888
# define environmental variables
environment:
# define port without exposing it. Only haproxy should have direct access to it
- PORT=8888
- API_BASE_URL=http://api:8000/
# redis env variables
- REDIS_HOST=redis_db
- REDIS_PORT=6379
- REDIS_PASS=dev_redispass
- TMP_CODESPACE_EXPIRE_UPDATE=1200
- CODESPACE_EXPIRE_UPDATE=1200
depends_on:
- api
loadbalancer:
image: haproxy:1.8
restart: always
ports:
- "8888:8888"
volumes:
- "./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg"
depends_on:
- websocket_server
links:
- websocket_server
deploy:
resources:
# set memory limit
limits:
memory: 500M
db:
image: postgres:13-alpine
ports:
- "5432:5432"
volumes:
- dev-db-data:/var/lib/postgres/data
# initial environment variables
environment:
- POSTGRES_DB=devdb
- POSTGRES_USER=devuser
- POSTGRES_PASSWORD=devpass
redis_db:
image: redis:6.2-alpine
restart: always
ports:
- '6379:6379'
command: redis-server --save 20 1 --loglevel warning --requirepass dev_redispass --notify-keyspace-events Kx
volumes:
dev-db-data:
driver: local