-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
245 lines (235 loc) · 8.88 KB
/
docker-compose.yml
File metadata and controls
245 lines (235 loc) · 8.88 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
# FlowEngine Portal - All-in-One Docker Compose
# Includes self-hosted Supabase (Postgres, Auth, REST API, Storage) + Next.js Portal
#
# Quick start (standalone):
# 1. ./setup.sh ← copies .env.docker → .env, creates coolify network, starts stack
# 2. Edit .env with your domain/passwords
# 3. docker compose up -d --build
# 4. Open http://your-server:3000 (or https://PORTAL_DOMAIN if behind Traefik)
#
# ⚠️ SITE_URL must match the public URL users open in their browser.
# NEXT_PUBLIC_SUPABASE_URL is set automatically to SITE_URL (browser → Next.js proxy → Kong).
#
# Generate JWT keys: https://supabase.com/docs/guides/self-hosting/docker#generate-api-keys
services:
# ============================================
# PostgreSQL - Database
# ============================================
postgres:
image: supabase/postgres:15.8.1.060
ports:
- "${POSTGRES_PORT:-5432}:5432"
environment:
POSTGRES_USER: supabase_admin
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: postgres
JWT_SECRET: ${JWT_SECRET}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./migrations/00-init-roles.sh:/docker-entrypoint-initdb.d/00-init-roles.sh
- ./migrations/add_portal_settings.sql:/docker-entrypoint-initdb.d/02-auth-compat.sql
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
# ============================================
# GoTrue - Authentication
# ============================================
auth:
image: supabase/gotrue:v2.170.0
depends_on:
postgres:
condition: service_healthy
environment:
GOTRUE_API_HOST: 0.0.0.0
GOTRUE_API_PORT: 9999
API_EXTERNAL_URL: ${API_EXTERNAL_URL:-http://localhost:8000}
GOTRUE_DB_DRIVER: postgres
GOTRUE_DB_DATABASE_URL: postgres://supabase_auth_admin:${POSTGRES_PASSWORD}@postgres:5432/postgres?search_path=auth
GOTRUE_SITE_URL: ${SITE_URL:-http://localhost:3000}
GOTRUE_URI_ALLOW_LIST: ${SITE_URL:-http://localhost:3000}/**,${ADDITIONAL_REDIRECT_URLS:-}
GOTRUE_DISABLE_SIGNUP: ${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: ${ENABLE_EMAIL_AUTOCONFIRM:-true}
GOTRUE_SMTP_HOST: ${SMTP_HOST:-}
GOTRUE_SMTP_PORT: ${SMTP_PORT:-587}
GOTRUE_SMTP_USER: ${SMTP_USER:-}
GOTRUE_SMTP_PASS: ${SMTP_PASS:-}
GOTRUE_SMTP_ADMIN_EMAIL: ${SMTP_FROM:-noreply@localhost}
GOTRUE_SMTP_SENDER_NAME: ${SMTP_SENDER_NAME:-FlowEngine}
GOTRUE_MAILER_URLPATHS_INVITE: /auth/callback
GOTRUE_MAILER_URLPATHS_CONFIRMATION: /auth/callback
GOTRUE_MAILER_URLPATHS_RECOVERY: /auth/callback
GOTRUE_EXTERNAL_GOOGLE_ENABLED: ${ENABLE_GOOGLE_AUTH:-false}
GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID:-}
GOTRUE_EXTERNAL_GOOGLE_SECRET: ${GOOGLE_CLIENT_SECRET:-}
GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI: ${API_EXTERNAL_URL:-http://localhost:8000}/auth/v1/callback
GOTRUE_EXTERNAL_GITHUB_ENABLED: ${ENABLE_GITHUB_AUTH:-false}
GOTRUE_EXTERNAL_GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID:-}
GOTRUE_EXTERNAL_GITHUB_SECRET: ${GITHUB_CLIENT_SECRET:-}
GOTRUE_EXTERNAL_GITHUB_REDIRECT_URI: ${API_EXTERNAL_URL:-http://localhost:8000}/auth/v1/callback
restart: unless-stopped
# ============================================
# PostgREST - RESTful API for Postgres
# ============================================
rest:
image: postgrest/postgrest:v12.2.8
depends_on:
postgres:
condition: service_healthy
environment:
PGRST_DB_URI: postgres://authenticator:${POSTGRES_PASSWORD}@postgres:5432/postgres
PGRST_DB_SCHEMAS: public,storage,graphql_public
PGRST_DB_ANON_ROLE: anon
PGRST_JWT_SECRET: ${JWT_SECRET}
PGRST_DB_USE_LEGACY_GUCS: "false"
restart: unless-stopped
# ============================================
# Supabase Storage - File storage (logos, uploads)
# ============================================
storage:
image: supabase/storage-api:v1.14.3
depends_on:
postgres:
condition: service_healthy
db-migrate:
condition: service_completed_successfully
environment:
ANON_KEY: ${ANON_KEY}
SERVICE_KEY: ${SERVICE_ROLE_KEY}
POSTGREST_URL: http://rest:3000
PGRST_JWT_SECRET: ${JWT_SECRET}
DATABASE_URL: postgres://supabase_storage_admin:${POSTGRES_PASSWORD}@postgres:5432/postgres
FILE_SIZE_LIMIT: 52428800
STORAGE_BACKEND: file
FILE_STORAGE_BACKEND_PATH: /var/lib/storage
TENANT_ID: stub
REGION: stub
GLOBAL_S3_BUCKET: stub
IS_MULTITENANT: "false"
volumes:
- storage_data:/var/lib/storage
restart: unless-stopped
# ============================================
# Realtime - WebSocket subscriptions
# ============================================
realtime:
image: supabase/realtime:v2.34.18
depends_on:
postgres:
condition: service_healthy
environment:
PORT: 4000
DB_HOST: postgres
DB_PORT: 5432
DB_USER: supabase_admin
DB_PASSWORD: ${POSTGRES_PASSWORD}
DB_NAME: postgres
DB_AFTER_CONNECT_QUERY: "SET search_path TO _realtime"
DB_ENC_KEY: supabaserealtime
API_JWT_SECRET: ${JWT_SECRET}
APP_NAME: realtime
FLY_ALLOC_ID: fly123
FLY_APP_NAME: realtime
SECRET_KEY_BASE: ${JWT_SECRET}
ERL_AFLAGS: "-proto_dist inet_tcp"
ENABLE_TAILSCALE: "false"
DNS_NODES: "''"
RLIMIT_NOFILE: ""
restart: unless-stopped
# ============================================
# Kong - API Gateway (routes all Supabase services)
# ============================================
kong:
image: kong:2.8.1
ports:
- "${KONG_HTTP_PORT:-8000}:8000"
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
volumes:
- ./docker/kong.yml:/var/lib/kong/kong.yml:ro
depends_on:
- auth
- rest
- storage
- realtime
restart: unless-stopped
# ============================================
# DB Migrations - Runs portal schema after GoTrue creates auth.users
# ============================================
db-migrate:
image: supabase/postgres:15.8.1.060
depends_on:
postgres:
condition: service_healthy
auth:
condition: service_started
environment:
PGPASSWORD: ${POSTGRES_PASSWORD}
volumes:
- ./migrations/supabase-schema.sql:/migrations/01-schema.sql
- ./migrations/seed.sql:/migrations/99-seed.sql
command: >
bash -c "
sleep 10 &&
psql -h postgres -U supabase_admin -d postgres -f /migrations/01-schema.sql || true &&
psql -h postgres -U supabase_admin -d postgres -f /migrations/99-seed.sql || true &&
psql -h postgres -U supabase_admin -d postgres -c \"NOTIFY pgrst, 'reload schema';\" || true
"
restart: "no"
# ============================================
# FlowEngine Portal - Next.js Application
# ============================================
portal:
build:
context: .
args:
NEXT_PUBLIC_SUPABASE_URL: ${SITE_URL:-http://localhost:3000}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${ANON_KEY}
NEXT_PUBLIC_APP_URL: ${SITE_URL:-http://localhost:3000}
environment:
NEXT_PUBLIC_SUPABASE_URL: ${SITE_URL:-http://localhost:3000}
SUPABASE_URL: http://kong:8000
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${ANON_KEY}
SUPABASE_SERVICE_ROLE_KEY: ${SERVICE_ROLE_KEY}
NEXT_PUBLIC_APP_URL: ${SITE_URL:-http://localhost:3000}
ENCRYPTION_SECRET: ${ENCRYPTION_SECRET}
depends_on:
postgres:
condition: service_healthy
kong:
condition: service_started
ports:
- "${PORTAL_PORT:-3000}:3000"
restart: unless-stopped
networks:
- default
- coolify
labels:
# Traefik / Coolify — only active when PORTAL_DOMAIN is set and Traefik is running.
# For standalone (no Traefik), these labels are ignored; use the port above instead.
- "traefik.enable=${PORTAL_DOMAIN:+true}"
- "traefik.http.routers.fe-portal.rule=Host(`${PORTAL_DOMAIN:-localhost}`)"
- "traefik.http.routers.fe-portal.entrypoints=http,https"
- "traefik.http.routers.fe-portal.tls=true"
- "traefik.http.routers.fe-portal.tls.certresolver=letsencrypt"
- "traefik.http.services.fe-portal.loadbalancer.server.port=3000"
- "traefik.docker.network=coolify"
volumes:
postgres_data:
storage_data:
networks:
coolify:
external: true