forked from CredenceOrg/Credence-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
162 lines (152 loc) · 4.56 KB
/
Copy pathdocker-compose.yml
File metadata and controls
162 lines (152 loc) · 4.56 KB
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
version: '3.8'
services:
# Prometheus - Metrics collection and storage
prometheus:
image: prom/prometheus:latest
container_name: credence-prometheus
ports:
- "9090:9090"
volumes:
- ./monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./monitoring/prometheus/alerts.yml:/etc/prometheus/alerts.yml
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=30d'
- '--storage.tsdb.retention.size=10GB'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- '--web.enable-lifecycle'
restart: unless-stopped
networks:
- monitoring
# Grafana - Visualization and dashboards
grafana:
image: grafana/grafana:latest
container_name: credence-grafana
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
- GF_SERVER_ROOT_URL=http://localhost:3001
- GF_INSTALL_PLUGINS=
volumes:
- grafana-data:/var/lib/grafana
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
depends_on:
- prometheus
restart: unless-stopped
networks:
- monitoring
# PostgreSQL - Database (optional, for local development)
postgres:
image: postgres:15-alpine
container_name: credence-postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=credence
- POSTGRES_PASSWORD=credence_dev
- POSTGRES_DB=credence
volumes:
- postgres-data:/var/lib/postgresql/data
restart: unless-stopped
networks:
- monitoring
# Redis - Cache (optional, for local development)
###############################################################################
# Credence Backend – Docker Compose for local development
#
# Services:
# backend – Express/TypeScript API (built from ./Dockerfile)
# postgres – PostgreSQL 16 database
# redis – Redis 7 in-memory store
#
# Usage:
# cp .env.example .env # create local env file
# docker compose up --build # start all services
# docker compose down -v # stop and remove volumes
###############################################################################
services:
# ---- Backend API --------------------------------------------------------
backend:
build:
context: .
dockerfile: Dockerfile
container_name: credence-backend
ports:
- "${PORT:-3000}:3000"
env_file:
- .env
environment:
# Override individual vars here if needed; .env takes precedence
NODE_ENV: development
PORT: 3000
DATABASE_URL: postgres://${POSTGRES_USER:-credence}:${POSTGRES_PASSWORD:-credence}@postgres:5432/${POSTGRES_DB:-credence}
REDIS_URL: redis://redis:6379
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
restart: unless-stopped
# Healthcheck hits the /api/health endpoint
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:3000/api/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# ---- PostgreSQL ---------------------------------------------------------
postgres:
image: postgres:16-alpine
container_name: credence-postgres
ports:
- "${POSTGRES_PORT:-5432}:5432"
environment:
POSTGRES_USER: ${POSTGRES_USER:-credence}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-credence}
POSTGRES_DB: ${POSTGRES_DB:-credence}
volumes:
# Persist data across restarts
- pgdata:/var/lib/postgresql/data
# Drop .sql files in ./init-db/ to auto-run on first start
- ./init-db:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-credence}"]
interval: 5s
timeout: 3s
retries: 5
# ---- Redis --------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: credence-redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
restart: unless-stopped
networks:
- monitoring
volumes:
prometheus-data:
grafana-data:
postgres-data:
redis-data:
networks:
monitoring:
driver: bridge
- "${REDIS_PORT:-6379}:6379"
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
volumes:
pgdata:
redisdata: