The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: improving the docker guide to make it easier to byo database
Copple3a23d636778c
diff --git a/docker/.env.example b/docker/.env.exampleindex 44b849e48ef..5a7d3c0da24 100644--- a/docker/.env.example+++ b/docker/.env.example@@ -1,12 +1,33 @@+############# Secrets# YOU MUST CHANGE THESE BEFORE GOING INTO PRODUCTION+############POSTGRES_PASSWORD=your-super-secret-and-long-postgres-passwordJWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-longANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GESERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q-# Auth+############+# Database - You can change these to any PostgreSQL database that has logical replication enabled.+############++POSTGRES_HOST=db+POSTGRES_DB=postgres+POSTGRES_USER=postgres+POSTGRES_PORT=5432++############+# API Proxy - Configuration for the Kong Reverse proxy.+############++KONG_HTTP_PORT=8000+KONG_HTTPS_PORT=8443+++############+# Auth - Configuration for the GoTrue authentication server.+############## GeneralSITE_URL=http://localhost:3000@@ -28,19 +49,9 @@ SMTP_SENDER_NAME=fake_senderENABLE_PHONE_SIGNUP=trueENABLE_PHONE_AUTOCONFIRM=true-# Ports+############+# Studio - Configuration for the Dashboard+############-## Studio portSTUDIO_PORT=3000--## API endpoint ports-KONG_HTTP_PORT=8000-KONG_HTTPS_PORT=8443--## DB port-POSTGRES_PORT=5432--# Studio--## Public REST endpoint - replace this if you intend to use Studio outside of localhost-PUBLIC_REST_URL=http://localhost:8000/rest/v1/+PUBLIC_REST_URL=http://localhost:8000/rest/v1/ # replace if you intend to use Studio outside of localhostdiff --git a/docker/docker-compose.yml b/docker/docker-compose.ymlindex 6e5fb21986c..b62db854bfd 100644--- a/docker/docker-compose.yml+++ b/docker/docker-compose.yml@@ -42,14 +42,14 @@ services:container_name: supabase-authimage: supabase/gotrue:v2.5.21depends_on:- - db+ - db # Disable this if you are using an external Postgres databaserestart: unless-stoppedenvironment:GOTRUE_API_HOST: 0.0.0.0GOTRUE_API_PORT: 9999GOTRUE_DB_DRIVER: postgres- GOTRUE_DB_DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres?search_path=auth+ GOTRUE_DB_DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?search_path=authGOTRUE_SITE_URL: ${SITE_URL}GOTRUE_URI_ALLOW_LIST: ${ADDITIONAL_REDIRECT_URLS}@@ -81,10 +81,10 @@ services:container_name: supabase-restimage: postgrest/postgrest:v9.0.0depends_on:- - db+ - db # Disable this if you are using an external Postgres databaserestart: unless-stoppedenvironment:- PGRST_DB_URI: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres+ PGRST_DB_URI: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}PGRST_DB_SCHEMAS: public,storage, graphql_publicPGRST_DB_ANON_ROLE: anonPGRST_JWT_SECRET: ${JWT_SECRET}@@ -94,13 +94,13 @@ services:container_name: supabase-realtimeimage: supabase/realtime:v0.22.4depends_on:- - db+ - db # Disable this if you are using an external Postgres databaserestart: unless-stoppedenvironment:- DB_HOST: db- DB_PORT: 5432- DB_NAME: postgres- DB_USER: postgres+ DB_HOST: ${POSTGRES_HOST}+ DB_PORT: ${POSTGRES_PORT}+ DB_NAME: ${POSTGRES_DB}+ DB_USER: ${POSTGRES_USER}DB_PASSWORD: ${POSTGRES_PASSWORD}DB_SSL: "false"PORT: 4000@@ -118,7 +118,7 @@ services:container_name: supabase-storageimage: supabase/storage-api:v0.10.0depends_on:- - db+ - db # Disable this if you are using an external Postgres database- restrestart: unless-stoppedenvironment:@@ -126,7 +126,7 @@ services:SERVICE_KEY: ${SERVICE_ROLE_KEY}POSTGREST_URL: http://rest:3000PGRST_JWT_SECRET: ${JWT_SECRET}- DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres+ DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}PGOPTIONS: -c search_path=storage,publicFILE_SIZE_LIMIT: 52428800STORAGE_BACKEND: file@@ -142,13 +142,14 @@ services:container_name: supabase-metaimage: supabase/postgres-meta:v0.29.0depends_on:- - db+ - db # Disable this if you are using an external Postgres databaserestart: unless-stoppedenvironment:PG_META_PORT: 8080- PG_META_DB_HOST: db+ PG_META_DB_HOST: ${POSTGRES_HOST}PG_META_DB_PASSWORD: ${POSTGRES_PASSWORD}+ # Comment out everything below this point if you are using an external Postgres databasedb:container_name: supabase-dbimage: supabase/postgres:14.1.0.21diff --git a/web/docs/guides/hosting/docker.mdx b/web/docs/guides/hosting/docker.mdxindex 89ebcfa9b03..f8a6fcc8e66 100644--- a/web/docs/guides/hosting/docker.mdx+++ b/web/docs/guides/hosting/docker.mdx@@ -71,14 +71,31 @@ The Docker setup doesn't include a management database for managing users and lo## Configuration+Each system can be [configured](/docs/guides/hosting/overview#configuration) to suit your particular use-case.+To keep the setup simple, we made some choices that may not be optimal for production:- the database is in the same machine as the servers-- the storage uses the filesystem backend instead of S3+- Storage uses the filesystem backend instead of S3+- Auth should be configured with a production-ready SMTP server++### Using an external database++We strongly [recommend](/docs/guides/hosting/overview#managing-your-database) that you decouple your database from `docker-compose` before deploying.+The middleware will run with any PostgreSQL database that has logical replication enabled. The following environment variables should be updated+in the `.env` file to point to your external database:++```env title=".env"+POSTGRES_PASSWORD=your-super-secret-and-long-postgres-password++POSTGRES_HOST=db+POSTGRES_DB=postgres+POSTGRES_USER=postgres+POSTGRES_PORT=5432+```++Once you can done this, you can safely comment out the `db` section of the `docker-compose` file, and remove any instances where the services `depends_on` the `db` image.-We strongly [recommend](/docs/guides/hosting/overview#managing-your-database) that you decouple your database-before deploying.-Each system can be [configured](/docs/guides/hosting/overview#configuration) to suit your particular use-case.## Deploying