-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcompose.chp-api.yaml
229 lines (219 loc) · 8.24 KB
/
compose.chp-api.yaml
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
version: '3.8'
services:
nginx-proxy:
build: nginx
restart: always
volumes:
- ./nginx/default.conf:/tmp/default.conf
environment:
- DJANGO_SERVER_ADDR=api:8000
- STATIC_SERVER_ADDR=static-fs:8080
- FLOWER_DASHBOARD_ADDR=dashboard:5556
- NEXTJS_SERVER_ADDR=frontend:3000
#- NEXTJS_SERVER_ADDR=api:8000
ports:
- "80:80"
depends_on:
- api
healthcheck:
test: ["CMD-SHELL", "curl --silent --fail localhost:80/health-check || exit 1"]
interval: 10s
timeout: 10s
retries: 3
command: /app/start.sh
api:
build:
context: ./chp_api
dockerfile: Dockerfile
restart: always
user: chp_api
ports:
- '8000:8000'
secrets:
- db-password
- django-key
- allowed-hosts
- csrf-trusted-origins
- django-superuser-username
- django-superuser-email
- django-superuser-password
environment:
- POSTGRES_DB=chpapi
- POSTGRES_USER=chpapi_user
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
- POSTGRES_HOST=db
- POSTGRES_PORT=5432
- DEBUG=0
# For Helm testing purposes
#- POSTGRES_PASSWORD=31173e51d8f78b56606d06dfb66a1b126630cdf4711bed9427025d8979976f31
#- SECRET_KEY=e1743ca40af220389cd1165d213e3d677f2d59c00d7b0f94e7a302c91f95f029
#- DJANGO_ALLOWED_HOSTS=localhost,chp.thayer.dartmouth.edu
- CSRF_TRUSTED_ORIGINS=http://localhost,https://chp.thayer.dartmouth.edu
#- DJANGO_SUPERUSER_USERNAME=chp_admin
#- DJANGO_SUPERUSER_PASSWORD=e12ff26f070819d9a72e317898148679680e6b3976e464b4102bd6eb18357919
- SECRET_KEY_FILE=/run/secrets/django-key
#- CSRF_TRUSTED_ORIGINS_FILE=/run/secrets/csrf-trusted-origins
- DJANGO_ALLOWED_HOSTS_FILE=/run/secrets/allowed-hosts
- DJANGO_SUPERUSER_USERNAME_FILE=/run/secrets/django-superuser-username
- DJANGO_SUPERUSER_EMAIL_FILE=/run/secrets/django-superuser-email
- DJANGO_SUPERUSER_PASSWORD_FILE=/run/secrets/django-superuser-password
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
# Uncomment this for production
#- DJANGO_SETTINGS_MODULE=mysite.settings.production
# Comment this for development
- DJANGO_SETTINGS_MODULE=chp_api.settings
# For Open Telemetry
- OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
- OTEL_TRACES_EXPORTER=jaeger
- OTEL_EXPORTER_JAEGER_AGENT_HOST=jaeger-otel-agent.sri
- OTEL_EXPORTER_JAEGER_AGENT_PORT=6831
depends_on:
- static-fs
- db
#condition: service_healthy
healthcheck:
#test: ["CMD-SHELL", "curl --silent --fail localhost:8000/flask-health-check || exit 1"]
interval: 10s
timeout: 10s
retries: 3
volumes:
- static-files:/home/chp_api/staticfiles
#command: uwsgi --http :8000 --max-requests=200 --master --pidfile=/tmp/project-master.pid --logto /tmp/mylog.log --module chp_api.wsgi:application
#command: opentelemetry-instrument --traces_exporter console --metrics_exporter console uwsgi --http :8000 --max-requests=200 --master --pidfile=/tmp/project-master.pid --module chp_api.wsgi:application
command: opentelemetry-instrument --traces_exporter jaeger --metrics_exporter console uwsgi --http :8000 --max-requests=200 --master --pidfile=/tmp/project-master.pid --module chp_api.wsgi:application
#command: gunicorn -c gunicorn.config.py -b 0.0.0.0:8000 chp_api.wsgi:application
#command: python3 manage.py runserver 0.0.0.0:8000
worker-api:
build:
context: ./chp_api
dockerfile: Dockerfile
restart: always
secrets:
- db-password
- django-key
- allowed-hosts
- django-superuser-username
- django-superuser-email
- django-superuser-password
environment:
- POSTGRES_DB=chpapi
- POSTGRES_USER=chpapi_user
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
- POSTGRES_HOST=db
- POSTGRES_PORT=5432
- DEBUG=0
# For Helm testing purposes
#- POSTGRES_PASSWORD=31173e51d8f78b56606d06dfb66a1b126630cdf4711bed9427025d8979976f31
#- SECRET_KEY=e1743ca40af220389cd1165d213e3d677f2d59c00d7b0f94e7a302c91f95f029
#- DJANGO_ALLOWED_HOSTS=localhost,chp.thayer.dartmouth.edu
- CSRF_TRUSTED_ORIGINS=http://localhost,https://chp.thayer.dartmouth.edu
#- DJANGO_SUPERUSER_USERNAME=chp_admin
#- DJANGO_SUPERUSER_PASSWORD=e12ff26f070819d9a72e317898148679680e6b3976e464b4102bd6eb18357919
- SECRET_KEY_FILE=/run/secrets/django-key
#- CSRF_TRUSTED_ORIGINS_FILE=/run/secrets/csrf-trusted-origins
- DJANGO_ALLOWED_HOSTS_FILE=/run/secrets/allowed-hosts
- DJANGO_SUPERUSER_USERNAME_FILE=/run/secrets/django-superuser-username
- DJANGO_SUPERUSER_EMAIL_FILE=/run/secrets/django-superuser-email
- DJANGO_SUPERUSER_PASSWORD_FILE=/run/secrets/django-superuser-password
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
command: celery -A chp_api worker -Q chp_api --loglevel=info
depends_on:
- api
- redis
dashboard:
build:
context: ./chp_api
dockerfile: Dockerfile
restart: always
secrets:
- db-password
- django-key
- allowed-hosts
- django-superuser-username
- django-superuser-email
- django-superuser-password
environment:
- POSTGRES_DB=chpapi
- POSTGRES_USER=chpapi_user
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
- POSTGRES_HOST=db
- POSTGRES_PORT=5432
- DEBUG=0
# For Helm testing purposes
#- POSTGRES_PASSWORD=31173e51d8f78b56606d06dfb66a1b126630cdf4711bed9427025d8979976f31
#- SECRET_KEY=e1743ca40af220389cd1165d213e3d677f2d59c00d7b0f94e7a302c91f95f029
#- DJANGO_ALLOWED_HOSTS=localhost,chp.thayer.dartmouth.edu
- CSRF_TRUSTED_ORIGINS=http://localhost,https://chp.thayer.dartmouth.edu
#- DJANGO_SUPERUSER_USERNAME=chp_admin
#- DJANGO_SUPERUSER_PASSWORD=e12ff26f070819d9a72e317898148679680e6b3976e464b4102bd6eb18357919
- SECRET_KEY_FILE=/run/secrets/django-key
#- CSRF_TRUSTED_ORIGINS_FILE=/run/secrets/csrf-trusted-origins
- DJANGO_ALLOWED_HOSTS_FILE=/run/secrets/allowed-hosts
- DJANGO_SUPERUSER_USERNAME_FILE=/run/secrets/django-superuser-username
- DJANGO_SUPERUSER_EMAIL_FILE=/run/secrets/django-superuser-email
- DJANGO_SUPERUSER_PASSWORD_FILE=/run/secrets/django-superuser-password
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
command: celery -A chp_api --broker=redis://redis:6379/0 flower --port=5555
ports:
- 5556:5555
depends_on:
- api
- redis
- worker-api
redis:
restart: always
image: redis:6-alpine
db:
image: postgres
restart: always
secrets:
- db-password
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=chpapi
- POSTGRES_USER=chpapi_user
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
# For Helm testing purposes
#- POSTGRES_PASSWORD=31173e51d8f78b56606d06dfb66a1b126630cdf4711bed9427025d8979976f31
expose:
- 5432
healthcheck:
test: [ "CMD", "pg_isready -d chpapi -U chpapi_user" ]
interval: 10s
timeout: 5s
retries: 5
static-fs:
image: halverneus/static-file-server:latest
restart: always
environment:
- FOLDER=/var/www
- DEBUG=true
expose:
- 8080
volumes:
- static-files:/var/www/static
volumes:
db-data:
static-files:
secrets:
allowed-hosts:
file: secrets/chp_api/allowed_hosts.txt
csrf-trusted-origins:
file: secrets/chp_api/csrf_trusted_origins.txt
db-password:
file: secrets/db/password.txt
django-key:
file: secrets/chp_api/secret_key.txt
django-superuser-username:
file: secrets/chp_api/django_superuser_username.txt
django-superuser-email:
file: secrets/chp_api/django_superuser_email.txt
django-superuser-password:
file: secrets/chp_api/django_superuser_password.txt