Skip to content

Commit 8a9fa07

Browse files
committed
docs: how to deploy
1 parent 50c2189 commit 8a9fa07

File tree

4 files changed

+153
-29
lines changed

4 files changed

+153
-29
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ It work by installing the library [sentry-dynamic-sampling-lib](https://github.c
1111

1212
Docs : [here](https://spikeelabs.github.io/sentry-dynamic-sampling-controller/)
1313

14+
How to deploy : [here](https://spikeelabs.github.io/sentry-dynamic-sampling-controller/how_to_deploy.html)
15+
1416

1517
## Install
1618
```bash

devops/docker-compose.example.yaml

Lines changed: 123 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
11
version: "3"
22

3+
x-env:
4+
&env
5+
environment:
6+
- ENV=debug
7+
- SECRET_KEY="very_secret"
8+
- POSTGRES_DB=sentry
9+
- POSTGRES_USER=sentry
10+
- POSTGRES_PASSWORD=sentry
11+
- POSTGRES_HOST=postgres
12+
- POSTGRES_PORT=5432
13+
- APP_CACHE_TIMEOUT=600
14+
- CACHE_REDIS_URL=redis://redis:6379
15+
- CACHE_TIMEOUT=120
16+
- DEFAULT_SAMPLE_RATE=0.1
17+
- DEFAULT_WSGI_IGNORE_PATHS="/health,/healthz,/health/,/healthz/"
18+
- MAX_BUMP_TIME_SEC=6000
19+
# oidc
20+
- OIDC_RP_CLIENT_ID=$OIDC_RP_CLIENT_ID
21+
- OIDC_RP_CLIENT_SECRET=$OIDC_RP_CLIENT_SECRET
22+
- OIDC_OP_AUTHORIZATION_ENDPOINT=$OIDC_OP_AUTHORIZATION_ENDPOINT
23+
- OIDC_OP_TOKEN_ENDPOINT=$OIDC_OP_TOKEN_ENDPOINT
24+
- OIDC_OP_USER_ENDPOINT=$OIDC_OP_USER_ENDPOINT
25+
- LOGIN_REDIRECT_URL=$LOGIN_REDIRECT_URL
26+
- LOGOUT_REDIRECT_URL=$LOGOUT_REDIRECT_URL
27+
- OIDC_OP_JWKS_ENDPOINT=$OIDC_OP_JWKS_ENDPOINT
28+
- OIDC_RP_SIGN_ALGO=RS256
29+
- STATIC_URL=http://localhost:8000/static/
30+
# rabbit
31+
- CELERY_BROKER_USER=sentry
32+
- CELERY_BROKER_PASSWORD=sentry
33+
- CELERY_BROKER_HOST=rabbitmq
34+
- CELERY_BROKER_PORT=5672
35+
# this is for nginx-proxy
36+
- VIRTUAL_HOST=localhost
37+
- VIRTUAL_PORT=8000
38+
- VIRTUAL_PATH=/
39+
340
services:
41+
42+
# serves as an ingress to prevent cors errors
43+
nginx-proxy:
44+
image: nginxproxy/nginx-proxy
45+
ports:
46+
- "8000:80"
47+
volumes:
48+
- /var/run/docker.sock:/tmp/docker.sock:ro
49+
450
postgres:
551
image: postgres:latest
652
environment:
@@ -9,6 +55,7 @@ services:
955
- POSTGRES_PASSWORD=sentry
1056
profiles:
1157
- data
58+
- all
1259
ports:
1360
- 5432:5432
1461
volumes:
@@ -18,53 +65,98 @@ services:
1865
image: 'bitnami/redis:latest'
1966
profiles:
2067
- data
68+
- all
2169
environment:
2270
- ALLOW_EMPTY_PASSWORD=yes
2371
ports:
2472
- 6379:6379
2573

74+
rabbitmq:
75+
image: bitnami/rabbitmq:3.11.8
76+
profiles:
77+
- data
78+
- all
79+
ports:
80+
- "15672:15672"
81+
- "5672:5672"
82+
environment:
83+
- RABBITMQ_DEFAULT_USER=sentry
84+
- RABBITMQ_DEFAULT_PASS=sentry
85+
- TZ=Europe/Paris
86+
87+
# serve the static files
2688
static:
2789
image: spklabs/sentry-dynamic-sampling-controller-static:alpha
28-
ports:
29-
- 8081:80
90+
expose:
91+
- 80
3092
profiles:
3193
- app
94+
- all
95+
environment:
96+
# this is for nginx-proxy
97+
- VIRTUAL_HOST=localhost
98+
- VIRTUAL_PORT=80
99+
- VIRTUAL_PATH=/static/
100+
101+
# deploy the app
102+
# the command is optional here
103+
# but it's customized to migrate the database an load the permissions
32104
app:
33105
image: spklabs/sentry-dynamic-sampling-controller:alpha
106+
command: >
107+
sh -c "python manage.py migrate && python manage.py loadpermissions && gunicorn controller.wsgi -c /app/config.py"
108+
34109
depends_on:
35110
- postgres
36111
- redis
37112
- static
38-
ports:
39-
- 8080:8000
113+
- rabbitmq
114+
expose:
115+
- 8000
40116
profiles:
41117
- app
42-
environment:
43-
- ENV=debug
44-
- SECRET_KEY="very_secret"
45-
- POSTGRES_DB=sentry
46-
- POSTGRES_USER=sentry
47-
- POSTGRES_PASSWORD=sentry
48-
- POSTGRES_HOST=postgres
49-
- POSTGRES_PORT=5432
50-
- APP_CACHE_TIMEOUT=600
51-
- CACHE_REDIS_URL=redis://redis:6379
52-
- CACHE_TIMEOUT=120
53-
- DEFAULT_SAMPLE_RATE=0.1
54-
- DEFAULT_WSGI_IGNORE_PATHS="/health,/healthz,/health/,/healthz/"
55-
- MAX_BUMP_TIME_SEC=6000
56-
# oidc
57-
- OIDC_RP_CLIENT_ID=$OIDC_RP_CLIENT_ID
58-
- OIDC_RP_CLIENT_SECRET=$OIDC_RP_CLIENT_SECRET
59-
- OIDC_OP_AUTHORIZATION_ENDPOINT=$OIDC_OP_AUTHORIZATION_ENDPOINT
60-
- OIDC_OP_TOKEN_ENDPOINT=$OIDC_OP_TOKEN_ENDPOINT
61-
- OIDC_OP_USER_ENDPOINT=$OIDC_OP_USER_ENDPOINT
62-
- LOGIN_REDIRECT_URL=$LOGIN_REDIRECT_URL
63-
- LOGOUT_REDIRECT_URL=$LOGOUT_REDIRECT_URL
64-
- OIDC_OP_JWKS_ENDPOINT=$OIDC_OP_JWKS_ENDPOINT
65-
- OIDC_RP_SIGN_ALGO=RS256
66-
- STATIC_URL=http://localhost:8081/static
118+
- all
119+
<<: *env
120+
121+
# Deploy the worker
122+
worker:
123+
image: spklabs/sentry-dynamic-sampling-controller:alpha
124+
command:
125+
- "celery"
126+
- "-A"
127+
- "controller"
128+
- "worker"
129+
- "-l"
130+
- "info"
131+
depends_on:
132+
- postgres
133+
- redis
134+
- rabbitmq
135+
profiles:
136+
- app
137+
- all
138+
<<: *env
139+
140+
# Deploy the beat
141+
beat:
142+
image: spklabs/sentry-dynamic-sampling-controller:alpha
143+
command:
144+
- "celery"
145+
- "-A"
146+
- "controller"
147+
- "beat"
148+
- "-l"
149+
- "info"
150+
depends_on:
151+
- postgres
152+
- redis
153+
- rabbitmq
154+
profiles:
155+
- app
156+
- all
157+
<<: *env
67158

159+
# This optional and it's used to monitor the API
68160
statsd-exporter:
69161
image: prom/statsd-exporter:v0.23.0
70162
ports:
@@ -77,6 +169,7 @@ services:
77169
command:
78170
- --statsd.mapping-config=/statsd/statsd.conf
79171

172+
# This optional and it's used to monitor the API
80173
prometheus:
81174
image: prom/prometheus
82175
profiles:
@@ -87,6 +180,7 @@ services:
87180
ports:
88181
- 9090:9090
89182

183+
# This optional and it's used to monitor the API
90184
grafana:
91185
image: grafana/grafana
92186
profiles:

docs/how_to_deploy.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
How to Deploy
2+
=============
3+
4+
Services needed
5+
---------------
6+
You will need:
7+
- PostgreSQL database
8+
- RabbitMQ
9+
- Redis
10+
- An OIDC provider (Keycloak)
11+
12+
Services to deployed
13+
--------------------
14+
You will need to deploy 4 services:
15+
- static (nginx container spklabs/sentry-dynamic-sampling-controller-static)
16+
- Django API (spklabs/sentry-dynamic-sampling-controller)
17+
- Celery beat (alternative entrypoint in spklabs/sentry-dynamic-sampling-controller)
18+
- Celery Worker (alternative entrypoint in spklabs/sentry-dynamic-sampling-controller)
19+
20+
21+
22+
Docker-compose
23+
--------------
24+
You can find this docker-compose in the devops folder
25+
26+
.. literalinclude:: ../devops/docker-compose.example.yaml
27+
:language: yaml

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
self
1717
how_does_it_work
18+
how_to_deploy
1819

1920

2021
.. toctree::

0 commit comments

Comments
 (0)