Skip to content

Commit c239e4f

Browse files
committed
Add sentry
1 parent ef826a7 commit c239e4f

File tree

4 files changed

+112
-4
lines changed

4 files changed

+112
-4
lines changed

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,18 @@ ALLOY_PORT=12345
2424
GRAFANA_PORT=3000
2525
GRAFANA_USER=admin
2626
GRAFANA_PASS=
27+
28+
# Sentry
29+
SENTRY_PORT=9002
30+
SENTRY_SECRET_KEY=
31+
SENTRY_SINGLE_ORGANIZATION=1
32+
SENTRY_EVENT_RETENTION_DAYS=30
33+
SENTRY_DB_NAME=sentry
34+
SENTRY_DB_USER=sentry
35+
SENTRY_DB_PASS=
36+
SENTRY_SERVER_EMAIL=sentry@chill.services
37+
SENTRY_SMTP_HOST=
38+
SENTRY_SMTP_PORT=587
39+
SENTRY_SMTP_USER=
40+
SENTRY_SMTP_PASS=
41+
SENTRY_SMTP_USE_TLS=true

AGENTS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Project Structure & Module Organization
44
This repository manages the infrastructure stack for the `chill` ecosystem.
55

6-
- `compose.yml`: main Docker Compose definition for MinIO, MongoDB, Prometheus, Loki, Alloy, and Grafana.
6+
- `compose.yml`: main Docker Compose definition for MinIO, MongoDB, Prometheus, Loki, Alloy, Grafana, and Sentry.
77
- `infra/`: service-level configuration (`nginx/`, `mongo/`, `prometheus/`, `loki/`, `alloy/`, `grafana/`).
88
- `scripts/`: helper scripts (`scripts/main.py`, `scripts/lib/s3.py`).
99
- `.github/workflows/deploy.yml`: deploy pipeline for `main`.
@@ -20,15 +20,15 @@ This repository manages the infrastructure stack for the `chill` ecosystem.
2020
## Coding Style & Naming Conventions
2121
- Python: PEP 8 style, 4-space indentation, `snake_case` for functions/variables, short module-level docstrings.
2222
- YAML/Compose: 2-space indentation, lowercase service names (`base-mongo`, `base-grafana`).
23-
- Environment variables: uppercase with clear prefixes (`MONGO_*`, `GRAFANA_*`, ...) with entity suffix (`USER` for admin/user login, `PASS` for admin/user password/key, `ID` for account/user/application ID, `TOKEN` for account/user/application secret token, `PORT` for container port exporting, ...).
23+
- Environment variables: uppercase with clear prefixes (`MONGO_*`, `GRAFANA_*`, `SENTRY_*`, ...) with entity suffix (`USER` for admin/user login, `PASS` for admin/user password/key, `ID` for account/user/application ID, `TOKEN` for account/user/application secret token, `PORT` for container port exporting, ...).
2424
- Keep config files service-scoped under `infra/<service>/` and avoid cross-service coupling in a single file.
2525

2626
## Testing Guidelines
2727
There is no formal automated test suite yet. Validate changes with infrastructure smoke checks:
2828

2929
1. `docker compose -p base config` (sanity-check Compose syntax).
3030
2. `make up` then `make status` (container health and ports).
31-
3. Verify affected service endpoints/UI paths (for example, `/grafana/` or `/prometheus/`).
31+
3. Verify affected service endpoints/UI paths (for example, `/grafana/`, `/prometheus/`, or Sentry on `${SENTRY_PORT}`).
3232

3333
## Commit & Pull Request Guidelines
3434
- Follow existing history style: short, imperative commit subjects (for example, `Fix mongodb on`, `Update routes`).
@@ -42,4 +42,5 @@ There is no formal automated test suite yet. Validate changes with infrastructur
4242
## Security & Configuration Tips
4343
- Never commit real secrets; copy `.env.example` to `.env` and keep credentials local.
4444
- Ensure `DATA_PATH` directories exist and are writable before `make up`.
45+
- Set strong local values for `SENTRY_SECRET_KEY` and `SENTRY_DB_PASS` before enabling Sentry.
4546
- Treat `make set` and TLS changes as production-impacting operations; review host/domain variables first.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A base of file storages and databases to support projects ecosystem
44
## Run
55
1. Create `.secrets/base.env` from `.env.example`
66

7-
2. Create folders `data/s3`, `data/mongo`, `data/prometheus`, `data/loki`, `data/alloy`, `data/grafana`, `data/redis`
7+
2. Create folders `data/s3`, `data/mongo`, `data/prometheus`, `data/loki`, `data/alloy`, `data/grafana`, `data/redis`, `data/sentry/redis`, `data/sentry/postgres`, `data/sentry/files`
88

99
3. Change configuration for MongoDB:
1010
```
@@ -20,3 +20,6 @@ sudo sysctl -w vm.max_map_count=262144
2020
7. Set up S3 buckets on `https://console.chill.services/`
2121

2222
8. Connect to MongoDB on `mongo mongo.chill.services -u <user> -p <pass> --authenticationDatabase admin`
23+
24+
9. Create Sentry admin user after stack startup:
25+
`docker exec -it base-sentry-web sentry createuser --superuser --email <email>`

compose.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
version: "3.11"
2+
x-sentry-env: &sentry_env
3+
SENTRY_SECRET_KEY: ${SENTRY_SECRET_KEY:-change-me}
4+
SENTRY_SINGLE_ORGANIZATION: ${SENTRY_SINGLE_ORGANIZATION:-1}
5+
SENTRY_EVENT_RETENTION_DAYS: ${SENTRY_EVENT_RETENTION_DAYS:-30}
6+
SENTRY_POSTGRES_HOST: sentry-postgres
7+
SENTRY_DB_NAME: ${SENTRY_DB_NAME:-sentry}
8+
SENTRY_DB_USER: ${SENTRY_DB_USER:-sentry}
9+
SENTRY_DB_PASSWORD: ${SENTRY_DB_PASS:-sentry}
10+
SENTRY_REDIS_HOST: sentry-redis
11+
SENTRY_REDIS_PORT: 6379
12+
SENTRY_SERVER_EMAIL: ${SENTRY_SERVER_EMAIL:-sentry@localhost}
13+
SENTRY_EMAIL_HOST: ${SENTRY_SMTP_HOST:-}
14+
SENTRY_EMAIL_PORT: ${SENTRY_SMTP_PORT:-587}
15+
SENTRY_EMAIL_USER: ${SENTRY_SMTP_USER:-}
16+
SENTRY_EMAIL_PASSWORD: ${SENTRY_SMTP_PASS:-}
17+
SENTRY_EMAIL_USE_TLS: ${SENTRY_SMTP_USE_TLS:-true}
18+
219
services:
320
s3:
421
image: minio/minio:latest
@@ -172,3 +189,75 @@ services:
172189
depends_on:
173190
- prometheus
174191
- loki
192+
193+
# ==========================================================================
194+
# SENTRY - Error aggregation, triage UI and alerting
195+
# ==========================================================================
196+
sentry-redis:
197+
image: redis:7.4-alpine
198+
container_name: base-sentry-redis
199+
restart: unless-stopped
200+
volumes:
201+
- ${DATA_PATH}/sentry/redis:/data
202+
command: redis-server --save 60 1 --loglevel warning
203+
healthcheck:
204+
test: ["CMD", "redis-cli", "ping"]
205+
interval: 15s
206+
timeout: 5s
207+
retries: 10
208+
209+
sentry-postgres:
210+
image: postgres:16-alpine
211+
container_name: base-sentry-postgres
212+
restart: unless-stopped
213+
environment:
214+
POSTGRES_DB: ${SENTRY_DB_NAME:-sentry}
215+
POSTGRES_USER: ${SENTRY_DB_USER:-sentry}
216+
POSTGRES_PASSWORD: ${SENTRY_DB_PASS:-sentry}
217+
volumes:
218+
- ${DATA_PATH}/sentry/postgres:/var/lib/postgresql/data
219+
healthcheck:
220+
test: ["CMD-SHELL", "pg_isready -U ${SENTRY_DB_USER:-sentry} -d ${SENTRY_DB_NAME:-sentry}"]
221+
interval: 15s
222+
timeout: 5s
223+
retries: 10
224+
225+
sentry-web:
226+
image: getsentry/sentry:latest
227+
container_name: base-sentry-web
228+
restart: unless-stopped
229+
environment: *sentry_env
230+
volumes:
231+
- ${DATA_PATH}/sentry/files:/var/lib/sentry/files
232+
command: sh -c "sentry upgrade --noinput && sentry run web"
233+
ports:
234+
- "${SENTRY_PORT:-9002}:9000"
235+
depends_on:
236+
sentry-postgres:
237+
condition: service_healthy
238+
sentry-redis:
239+
condition: service_healthy
240+
241+
sentry-worker:
242+
image: getsentry/sentry:latest
243+
container_name: base-sentry-worker
244+
restart: unless-stopped
245+
environment: *sentry_env
246+
volumes:
247+
- ${DATA_PATH}/sentry/files:/var/lib/sentry/files
248+
command: run worker
249+
depends_on:
250+
sentry-web:
251+
condition: service_started
252+
253+
sentry-scheduler:
254+
image: getsentry/sentry:latest
255+
container_name: base-sentry-scheduler
256+
restart: unless-stopped
257+
environment: *sentry_env
258+
volumes:
259+
- ${DATA_PATH}/sentry/files:/var/lib/sentry/files
260+
command: run cron
261+
depends_on:
262+
sentry-web:
263+
condition: service_started

0 commit comments

Comments
 (0)