Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
291 lines (280 loc) · 9.16 KB
/
Copy pathdocker-compose.yml
File metadata and controls
291 lines (280 loc) · 9.16 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
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# ---------------------------------------------------------------------------
# Ardent Forge -- Self-Hosted Docker Composition
#
# Quick start:
# cp .env.example .env
# ./scripts/generate-keys.sh
# docker compose up -d
#
# See docs/self-hosting.md for the full setup guide.
# ---------------------------------------------------------------------------
networks:
ardent-forge-net:
driver: bridge
volumes:
pgdata:
caddy_data:
caddy_config:
services:
# -------------------------------------------------------------------------
# PostgreSQL -- persistent data store
# -------------------------------------------------------------------------
db:
image: supabase/postgres:15.8.1.060
restart: unless-stopped
networks:
- ardent-forge-net
volumes:
- pgdata:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:-postgres}
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 10s
timeout: 5s
retries: 5
# -------------------------------------------------------------------------
# Kong -- API gateway for Supabase services
# -------------------------------------------------------------------------
kong:
image: kong:2.8.1
restart: unless-stopped
networks:
- ardent-forge-net
depends_on:
db:
condition: service_healthy
environment:
KONG_DATABASE: 'off'
KONG_DECLARATIVE_CONFIG: /var/lib/kong/kong.yml
KONG_DNS_ORDER: LAST,A,CNAME
KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth
KONG_NGINX_PROXY_PROXY_BUFFER_SIZE: 160k
KONG_NGINX_PROXY_PROXY_BUFFERS: 64 160k
ANON_KEY: ${ANON_KEY}
SERVICE_ROLE_KEY: ${SERVICE_ROLE_KEY}
volumes:
- ./docker/kong/kong.yml:/var/lib/kong/kong.yml:ro
healthcheck:
test: ['CMD', 'kong', 'health']
interval: 10s
timeout: 5s
retries: 5
# -------------------------------------------------------------------------
# GoTrue -- authentication service
# -------------------------------------------------------------------------
auth:
image: supabase/gotrue:v2.175.0
restart: unless-stopped
networks:
- ardent-forge-net
depends_on:
db:
condition: service_healthy
migrations:
condition: service_completed_successfully
environment:
GOTRUE_API_HOST: '0.0.0.0'
GOTRUE_API_PORT: '9999'
API_EXTERNAL_URL: ${SITE_URL}
GOTRUE_DB_DRIVER: postgres
GOTRUE_DB_DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-postgres}?sslmode=disable
GOTRUE_SITE_URL: ${SITE_URL}
GOTRUE_URI_ALLOW_LIST: '*'
GOTRUE_DISABLE_SIGNUP: 'false'
GOTRUE_JWT_ADMIN_ROLES: service_role
GOTRUE_JWT_AUD: authenticated
GOTRUE_JWT_DEFAULT_GROUP_NAME: authenticated
GOTRUE_JWT_EXP: '3600'
GOTRUE_JWT_SECRET: ${JWT_SECRET}
GOTRUE_EXTERNAL_EMAIL_ENABLED: 'true'
GOTRUE_MAILER_AUTOCONFIRM: 'false'
GOTRUE_SMTP_HOST: ${SMTP_HOST:-}
GOTRUE_SMTP_PORT: ${SMTP_PORT:-587}
GOTRUE_SMTP_USER: ${SMTP_USER:-}
GOTRUE_SMTP_PASS: ${SMTP_PASS:-}
GOTRUE_SMTP_SENDER_NAME: ${SMTP_SENDER_EMAIL:-}
GOTRUE_EXTERNAL_GOOGLE_ENABLED: ${GOOGLE_ENABLED:-false}
GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID:-}
GOTRUE_EXTERNAL_GOOGLE_SECRET: ${GOOGLE_CLIENT_SECRET:-}
GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI: ${SITE_URL}/auth/v1/callback
healthcheck:
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:9999/health']
interval: 10s
timeout: 5s
retries: 5
# -------------------------------------------------------------------------
# PostgREST -- RESTful API over PostgreSQL
# -------------------------------------------------------------------------
rest:
image: postgrest/postgrest:v12.2.8
restart: unless-stopped
networks:
- ardent-forge-net
depends_on:
db:
condition: service_healthy
migrations:
condition: service_completed_successfully
environment:
PGRST_DB_URI: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-postgres}
PGRST_DB_SCHEMA: public,storage,graphql_public
PGRST_DB_ANON_ROLE: anon
PGRST_JWT_SECRET: ${JWT_SECRET}
PGRST_DB_USE_LEGACY_GUCS: 'false'
healthcheck:
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:3000/']
interval: 10s
timeout: 5s
retries: 5
# -------------------------------------------------------------------------
# Realtime -- WebSocket subscriptions for live updates
# -------------------------------------------------------------------------
realtime:
image: supabase/realtime:v2.34.48
restart: unless-stopped
networks:
- ardent-forge-net
depends_on:
db:
condition: service_healthy
migrations:
condition: service_completed_successfully
environment:
PORT: '4000'
DB_HOST: db
DB_PORT: '5432'
DB_USER: postgres
DB_PASSWORD: ${POSTGRES_PASSWORD}
DB_NAME: ${POSTGRES_DB:-postgres}
DB_AFTER_CONNECT_QUERY: 'SET search_path TO _realtime'
DB_ENC_KEY: ${REALTIME_DB_ENC_KEY}
API_JWT_SECRET: ${JWT_SECRET}
APP_NAME: realtime
FLY_ALLOC_ID: fly123 # required by realtime image startup script; value is unused in self-hosted mode
FLY_APP_NAME: realtime
SECRET_KEY_BASE: ${REALTIME_SECRET_KEY_BASE}
ERL_AFLAGS: -proto_dist inet_tcp
ENABLE_TAILSCALE: 'false'
DNS_NODES: "''"
RLIMIT_NOFILE: '65536'
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:4000/']
interval: 10s
timeout: 5s
retries: 5
command: >
sh -c "/app/bin/migrate && /app/bin/server"
# -------------------------------------------------------------------------
# Supabase Studio -- admin dashboard (optional)
# Enable with: docker compose --profile studio up -d
# Or set COMPOSE_PROFILES=studio in your .env
# -------------------------------------------------------------------------
studio:
image: supabase/studio:latest
profiles: [studio]
restart: unless-stopped
networks:
- ardent-forge-net
depends_on:
kong:
condition: service_healthy
environment:
STUDIO_PG_META_URL: http://kong:8000/pg
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
DEFAULT_ORGANIZATION_NAME: 'Ardent Forge'
DEFAULT_PROJECT_NAME: 'ardent-forge'
SUPABASE_URL: http://kong:8000
SUPABASE_PUBLIC_URL: ${SITE_URL}
SUPABASE_ANON_KEY: ${ANON_KEY}
SUPABASE_SERVICE_KEY: ${SERVICE_ROLE_KEY}
AUTH_JWT_SECRET: ${JWT_SECRET}
NEXT_PUBLIC_ENABLE_LOGS: 'false'
healthcheck:
test:
[
'CMD',
'node',
'-e',
"require('http').get('http://localhost:3000/api/profile', (r) => { process.exit(r.statusCode === 200 ? 0 : 1) })",
]
interval: 10s
timeout: 5s
retries: 5
# -------------------------------------------------------------------------
# Migration runner -- applies SQL schema, then exits
# -------------------------------------------------------------------------
migrations:
build:
context: .
dockerfile: docker/migrations/Dockerfile
networks:
- ardent-forge-net
depends_on:
db:
condition: service_healthy
environment:
POSTGRES_HOST: db
POSTGRES_PORT: '5432'
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:-postgres}
restart: on-failure
# -------------------------------------------------------------------------
# Web app -- Vite production build served by nginx
# -------------------------------------------------------------------------
web:
build:
context: .
dockerfile: docker/web/Dockerfile
args:
VITE_SUPABASE_URL: ${SITE_URL}
VITE_SUPABASE_PUBLISHABLE_KEY: ${ANON_KEY}
restart: unless-stopped
networks:
- ardent-forge-net
depends_on:
migrations:
condition: service_completed_successfully
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:80/']
interval: 30s
timeout: 10s
retries: 3
# -------------------------------------------------------------------------
# Caddy -- reverse proxy with automatic TLS
# -------------------------------------------------------------------------
caddy:
image: caddy:2-alpine
restart: unless-stopped
networks:
- ardent-forge-net
ports:
- '${HTTP_PORT:-80}:${HTTP_PORT:-80}'
- '${HTTPS_PORT:-443}:${HTTPS_PORT:-443}'
volumes:
- ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
web:
condition: service_healthy
kong:
condition: service_healthy
environment:
SITE_URL: ${SITE_URL}
ANON_KEY: ${ANON_KEY}
healthcheck:
test:
[
'CMD',
'wget',
'--no-verbose',
'--tries=1',
'--spider',
'http://localhost:${HTTP_PORT:-80}/',
]
interval: 10s
timeout: 5s
retries: 3