Skip to content

Instantly share code, notes, and snippets.

@bhvngt
Created December 21, 2022 04:29
Show Gist options
  • Save bhvngt/58ff9a5a8a551ba3fdf48204635af2e3 to your computer and use it in GitHub Desktop.
Save bhvngt/58ff9a5a8a551ba3fdf48204635af2e3 to your computer and use it in GitHub Desktop.
supabase self-hosted docker compose
version: "3.8"
services:
studio:
container_name: supabase-studio
image: supabase/studio:latest
restart: unless-stopped
ports:
- ${STUDIO_PORT}:3000/tcp
environment:
SUPABASE_URL: http://kong:8000
STUDIO_PG_META_URL: http://meta:8080
SUPABASE_ANON_KEY: ${SUPABASE_ANON_KEY}
SUPABASE_SERVICE_KEY: ${SUPABASE_SERVICE_KEY}
kong:
container_name: supabase-kong
image: kong:2.1
restart: unless-stopped
ports:
- ${KONG_HTTP_PORT}:8000/tcp
- ${KONG_HTTPS_PORT}:8443/tcp
environment:
KONG_DATABASE: "off"
KONG_DECLARATIVE_CONFIG: /var/lib/kong/kong.yml
# https://github.com/supabase/cli/issues/14
KONG_DNS_ORDER: LAST,A,CNAME
KONG_PLUGINS: request-transformer,cors,key-auth,acl
volumes:
- ./volumes/api/kong.yml:/var/lib/kong/kong.yml
auth:
container_name: supabase-auth
image: supabase/gotrue:v2.40.0
depends_on:
- db
restart: unless-stopped
environment:
GOTRUE_API_HOST: 0.0.0.0
GOTRUE_API_PORT: 9999
GOTRUE_DB_DRIVER: postgres
GOTRUE_DB_DATABASE_URL: ${DOCKER_PGURL}?search_path=auth
GOTRUE_SITE_URL: ${SITE_URL}
GOTRUE_URI_ALLOW_LIST: ${ADDITIONAL_REDIRECT_URLS}
GOTRUE_DISABLE_SIGNUP: ${DISABLE_SIGNUP}
GOTRUE_JWT_SECRET: ${JWT_SECRET}
GOTRUE_JWT_EXP: ${JWT_EXPIRY}
GOTRUE_JWT_DEFAULT_GROUP_NAME: authenticated
GOTRUE_EXTERNAL_EMAIL_ENABLED: ${ENABLE_EMAIL_SIGNUP}
GOTRUE_MAILER_AUTOCONFIRM: ${ENABLE_EMAIL_AUTOCONFIRM}
GOTRUE_EXTERNAL_GOOGLE_ENABLED: ${EXTERNAL_GOOGLE_ENABLED}
GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID: ${EXTERNAL_GOOGLE_CLIENT_ID}
GOTRUE_EXTERNAL_GOOGLE_SECRET: ${EXTERNAL_GOOGLE_SECRET}
GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI: ${EXTERNAL_GOOGLE_REDIRECT_URI}
GOTRUE_SMTP_ADMIN_EMAIL: ${SMTP_ADMIN_EMAIL}
GOTRUE_SMTP_HOST: ${SMTP_HOST}
GOTRUE_SMTP_PORT: ${SMTP_PORT}
GOTRUE_SMTP_USER: ${SMTP_USER}
GOTRUE_SMTP_PASS: ${SMTP_PASS}
GOTRUE_SMTP_SENDER_NAME: ${SMTP_SENDER_NAME}
GOTRUE_MAILER_URLPATHS_INVITE: http://${HOST}:${KONG_HTTP_PORT}/auth/v1/verify
GOTRUE_MAILER_URLPATHS_CONFIRMATION: http://${HOST}:${KONG_HTTP_PORT}/auth/v1/verify
GOTRUE_MAILER_URLPATHS_RECOVERY: /auth/v1/verify
GOTRUE_MAILER_URLPATHS_EMAIL_CHANGE: /auth/v1/verify
GOTRUE_RATE_LIMIT_EMAIL_SENT: 10000
GOTRUE_EXTERNAL_PHONE_ENABLED: ${ENABLE_PHONE_SIGNUP}
GOTRUE_SMS_AUTOCONFIRM: ${ENABLE_PHONE_AUTOCONFIRM}
rest:
container_name: supabase-rest
image: postgrest/postgrest:v10.1.0
depends_on:
- db
restart: unless-stopped
ports:
- ${POSTGREST_PORT}:3000/tcp
environment:
PGRST_DB_URI: ${DOCKER_PGURL}
PGRST_DB_SCHEMAS: ${PGRST_DB_SCHEMAS}
PGRST_DB_TX_END: ${PGRST_DB_TX_END}
PGRST_DB_ANON_ROLE: anon
PGRST_JWT_SECRET: ${JWT_SECRET}
PGRST_LOG_LEVEL: info
PGRST_DB_USE_LEGACY_GUCS: "false"
# realtime:
# container_name: supabase-realtime
# image: supabase/realtime:v0.25.1
# depends_on:
# - db
# restart: unless-stopped
# environment:
# DB_HOST: db
# DB_PORT: 5432
# DB_NAME: ${PGDATABASE}
# DB_USER: ${PGUSER}
# DB_PASSWORD: ${PGPASSWORD}
# DB_SSL: "false"
# PORT: 4000
# JWT_SECRET: ${JWT_SECRET}
# REPLICATION_MODE: RLS
# REPLICATION_POLL_INTERVAL: 100
# SECURE_CHANNELS: "true"
# SLOT_NAME: supabase_realtime_rls
# TEMPORARY_SLOT: "true"
# command: >
# bash -c "./prod/rel/realtime/bin/realtime eval Realtime.Release.migrate
# && ./prod/rel/realtime/bin/realtime start"
realtime:
hostname: realtime-dev.realtime
container_name: supabase-realtime
image: supabase/realtime:v1.0.0-rc.14
depends_on:
- db
restart: unless-stopped
ports:
- "4100:4000"
environment:
PORT: 4000
DB_HOST: db
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: postgres
DB_NAME: postgres
DB_ENC_KEY: supabaserealtime
DB_AFTER_CONNECT_QUERY: 'SET search_path TO _realtime'
API_JWT_SECRET: your-super-secret-jwt-token-with-at-least-32-characters-long
FLY_ALLOC_ID: fly123
FLY_APP_NAME: realtime
SECRET_KEY_BASE: UpNVntn3cDxHJpq99YMc1T1AQgQpc8kfYTuRgBiYa15BLrx8etQoXz3gZv1/u2oq
ERL_AFLAGS: -proto_dist inet_tcp
ENABLE_TAILSCALE: false
DNS_NODES: "''"
command: sh -c "/app/bin/migrate && /app/bin/server"
storage:
container_name: supabase-storage
image: supabase/storage-api:v0.26.1
depends_on:
- db
- rest
restart: unless-stopped
environment:
ANON_KEY: ${SUPABASE_ANON_KEY}
SERVICE_KEY: ${SUPABASE_SERVICE_KEY}
POSTGREST_URL: http://rest:3000
PGRST_JWT_SECRET: ${JWT_SECRET}
DATABASE_URL: ${DOCKER_PGURL}
PGOPTIONS: -c search_path=storage,public
FILE_SIZE_LIMIT: 52428800
STORAGE_BACKEND: file
FILE_STORAGE_BACKEND_PATH: /var/lib/storage
TENANT_ID: stub
# TODO: https://github.com/supabase/storage-api/issues/55
REGION: stub
GLOBAL_S3_BUCKET: stub
volumes:
- ./volumes/storage:/var/lib/storage
meta:
container_name: supabase-meta
image: supabase/postgres-meta:v0.54.0
depends_on:
- db
restart: unless-stopped
environment:
PG_META_PORT: 8080
PG_META_DB_HOST: db
PG_META_DB_PASSWORD: ${PGPASSWORD}
db:
container_name: supabase-db
image: supabase/postgres:15.1.0.14
command: >
postgres -c config_file=/etc/postgresql/postgresql.conf
-c log_statement=all -c logging_collector=on
-c log_destination=csvlog -c log_directory=/var/log/postgresql
-c log_filename=postgresql -c log_min_messages=fatal
restart: unless-stopped
ports:
- ${PGPORT}:5432
environment:
POSTGRES_PASSWORD: ${PGPASSWORD}
volumes:
- /var/lib/postgresql/data
- ./volumes/db/init:/docker-entrypoint-initdb.d
- ${PROJECT_ROOT}/data/supabase/schema:/schema
mail:
container_name: inbucket
image: inbucket/inbucket:latest
depends_on:
- db
ports:
- ${INBUCKET_PORT}:9000/tcp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment