-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
158 lines (150 loc) · 4.08 KB
/
docker-compose.yml
File metadata and controls
158 lines (150 loc) · 4.08 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
services:
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: studykit_development
volumes:
- db_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
command: redis-server --appendonly yes --maxmemory-policy noeviction
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
api:
build:
context: .
dockerfile: apps/api/Dockerfile
environment:
NODE_ENV: development
API_HOST: 0.0.0.0
API_PORT: 3100
DATABASE_URL: postgres://postgres:postgres@db:5432/studykit_development
REDIS_URL: redis://redis:6379
JWT_SECRET: ${JWT_SECRET:-change_me_with_min_32_chars_secret}
JWT_ISSUER: studykit-api
JWT_AUDIENCE: studykit-frontend
CORS_ORIGINS: http://localhost:5173,http://localhost:3001
TRUST_PROXY: "false"
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "3100:3100"
volumes:
- ./apps/api:/app/apps/api
worker:
build:
context: .
dockerfile: apps/worker/Dockerfile
environment:
DATABASE_URL: postgres://postgres:postgres@db:5432/studykit_development
REDIS_URL: redis://redis:6379
EXECUTOR_URL: http://executor:3200
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
executor:
condition: service_healthy
executor:
build:
context: .
dockerfile: apps/executor/Dockerfile
environment:
EXECUTOR_HOST: 0.0.0.0
EXECUTOR_PORT: 3200
ports:
- "3200:3200"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3200/health"]
interval: 10s
timeout: 5s
retries: 3
frontend:
build:
context: .
dockerfile: apps/frontend/Dockerfile
environment:
VITE_API_URL: http://localhost:3100
ports:
- "5173:5173"
volumes:
- ./apps/frontend:/app/apps/frontend
- frontend_node_modules:/app/apps/frontend/node_modules
depends_on:
- api
directus:
image: directus/directus:11.8.0
environment:
KEY: ${DIRECTUS_KEY:-change_this_directus_key_32_chars_min}
SECRET: ${DIRECTUS_SECRET:-change_this_directus_secret_32_chars_min}
DB_CLIENT: pg
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: studykit_development
DB_USER: postgres
DB_PASSWORD: postgres
DB_SCHEMA: directus
ADMIN_EMAIL: ${DIRECTUS_ADMIN_EMAIL:-admin@studykit.dev}
ADMIN_PASSWORD: ${DIRECTUS_ADMIN_PASSWORD:-change_me_please}
CORS_ENABLED: "true"
CORS_ORIGIN: "http://localhost:5173,http://localhost:3001"
depends_on:
db:
condition: service_healthy
ports:
- "8055:8055"
volumes:
- directus_uploads:/directus/uploads
db-init:
image: postgres:16
depends_on:
db:
condition: service_healthy
environment:
PGHOST: db
PGPORT: "5432"
PGDATABASE: studykit_development
PGUSER: postgres
PGPASSWORD: postgres
volumes:
- ./apps/api/db:/docker-entrypoint-initdb.d
- ./apps/api/db/schema.sql:/schema.sql
entrypoint: ["bash", "-c"]
command:
- |
echo "Waiting for database..."
until pg_isready -h $$PGHOST -p $$PGPORT -U $$PGUSER; do
echo "Database is unavailable - sleeping"
sleep 2
done
echo "Database is ready!"
echo "Running schema..."
psql -h $$PGHOST -p $$PGPORT -U $$PGUSER -d $$PGDATABASE -f /schema.sql || true
echo "Running seed..."
psql -h $$PGHOST -p $$PGPORT -U $$PGUSER -d $$PGDATABASE -f /docker-entrypoint-initdb.d/seed.sql || true
echo "Database initialization complete"
volumes:
db_data:
redis_data:
frontend_node_modules:
directus_uploads: