From 96a7a01b92ca92605f646fe8e0d36727f8db9a13 Mon Sep 17 00:00:00 2001 From: Andrei Canta Date: Fri, 26 Jul 2024 11:10:05 +0300 Subject: [PATCH] refactor --- supabase/.env.example | 105 ------------------ supabase/.gitignore | 5 - supabase/README.md | 6 - supabase/code/README.md | 3 + supabase/{ => code}/dev/data.sql | 0 .../{ => code}/dev/docker-compose.dev.yml | 0 supabase/{ => code}/docker-compose.s3.yml | 0 supabase/{ => code}/docker-compose.yml | 20 ++++ supabase/{ => code}/volumes/api/kong.yml | 0 supabase/{ => code}/volumes/db/init/data.sql | 0 supabase/{ => code}/volumes/db/jwt.sql | 0 supabase/{ => code}/volumes/db/logs.sql | 0 supabase/{ => code}/volumes/db/realtime.sql | 0 supabase/{ => code}/volumes/db/roles.sql | 0 supabase/{ => code}/volumes/db/webhooks.sql | 0 .../volumes/functions/hello/index.ts | 0 .../volumes/functions/main/index.ts | 0 supabase/{ => code}/volumes/logs/vector.yml | 0 supabase/repo | 1 + supabase/update.sh | 4 + 20 files changed, 28 insertions(+), 116 deletions(-) delete mode 100644 supabase/.env.example delete mode 100644 supabase/.gitignore create mode 100644 supabase/code/README.md rename supabase/{ => code}/dev/data.sql (100%) rename supabase/{ => code}/dev/docker-compose.dev.yml (100%) rename supabase/{ => code}/docker-compose.s3.yml (100%) rename supabase/{ => code}/docker-compose.yml (95%) rename supabase/{ => code}/volumes/api/kong.yml (100%) rename supabase/{ => code}/volumes/db/init/data.sql (100%) rename supabase/{ => code}/volumes/db/jwt.sql (100%) rename supabase/{ => code}/volumes/db/logs.sql (100%) rename supabase/{ => code}/volumes/db/realtime.sql (100%) rename supabase/{ => code}/volumes/db/roles.sql (100%) rename supabase/{ => code}/volumes/db/webhooks.sql (100%) rename supabase/{ => code}/volumes/functions/hello/index.ts (100%) rename supabase/{ => code}/volumes/functions/main/index.ts (100%) rename supabase/{ => code}/volumes/logs/vector.yml (100%) create mode 160000 supabase/repo create mode 100644 supabase/update.sh diff --git a/supabase/.env.example b/supabase/.env.example deleted file mode 100644 index 132fe8f..0000000 --- a/supabase/.env.example +++ /dev/null @@ -1,105 +0,0 @@ -############ -# Secrets -# YOU MUST CHANGE THESE BEFORE GOING INTO PRODUCTION -############ - -POSTGRES_PASSWORD=your-super-secret-and-long-postgres-password -JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long -ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE -SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q -DASHBOARD_USERNAME=supabase -DASHBOARD_PASSWORD=this_password_is_insecure_and_should_be_updated - -############ -# Database - You can change these to any PostgreSQL database that has logical replication enabled. -############ - -POSTGRES_HOST=db -POSTGRES_DB=postgres -POSTGRES_PORT=5432 -# default user is postgres - -############ -# API Proxy - Configuration for the Kong Reverse proxy. -############ - -KONG_HTTP_PORT=8000 -KONG_HTTPS_PORT=8443 - - -############ -# API - Configuration for PostgREST. -############ - -PGRST_DB_SCHEMAS=public,storage,graphql_public - - -############ -# Auth - Configuration for the GoTrue authentication server. -############ - -## General -SITE_URL=http://localhost:3000 -ADDITIONAL_REDIRECT_URLS= -JWT_EXPIRY=3600 -DISABLE_SIGNUP=false -API_EXTERNAL_URL=http://localhost:8000 - -## Mailer Config -MAILER_URLPATHS_CONFIRMATION="/auth/v1/verify" -MAILER_URLPATHS_INVITE="/auth/v1/verify" -MAILER_URLPATHS_RECOVERY="/auth/v1/verify" -MAILER_URLPATHS_EMAIL_CHANGE="/auth/v1/verify" - -## Email auth -ENABLE_EMAIL_SIGNUP=true -ENABLE_EMAIL_AUTOCONFIRM=false -SMTP_ADMIN_EMAIL=admin@example.com -SMTP_HOST=supabase-mail -SMTP_PORT=2500 -SMTP_USER=fake_mail_user -SMTP_PASS=fake_mail_password -SMTP_SENDER_NAME=fake_sender -ENABLE_ANONYMOUS_USERS=false - -## Phone auth -ENABLE_PHONE_SIGNUP=true -ENABLE_PHONE_AUTOCONFIRM=true - - -############ -# Studio - Configuration for the Dashboard -############ - -STUDIO_DEFAULT_ORGANIZATION=Default Organization -STUDIO_DEFAULT_PROJECT=Default Project - -STUDIO_PORT=3000 -# replace if you intend to use Studio outside of localhost -SUPABASE_PUBLIC_URL=http://localhost:8000 - -# Enable webp support -IMGPROXY_ENABLE_WEBP_DETECTION=true - -############ -# Functions - Configuration for Functions -############ -# NOTE: VERIFY_JWT applies to all functions. Per-function VERIFY_JWT is not supported yet. -FUNCTIONS_VERIFY_JWT=false - -############ -# Logs - Configuration for Logflare -# Please refer to https://supabase.com/docs/reference/self-hosting-analytics/introduction -############ - -LOGFLARE_LOGGER_BACKEND_API_KEY=your-super-secret-and-long-logflare-key - -# Change vector.toml sinks to reflect this change -LOGFLARE_API_KEY=your-super-secret-and-long-logflare-key - -# Docker socket location - this value will differ depending on your OS -DOCKER_SOCKET_LOCATION=/var/run/docker.sock - -# Google Cloud Project details -GOOGLE_PROJECT_ID=GOOGLE_PROJECT_ID -GOOGLE_PROJECT_NUMBER=GOOGLE_PROJECT_NUMBER diff --git a/supabase/.gitignore b/supabase/.gitignore deleted file mode 100644 index a1e9dc6..0000000 --- a/supabase/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -volumes/db/data -volumes/storage -.env -test.http -docker-compose.override.yml diff --git a/supabase/README.md b/supabase/README.md index 57bc92a..fc53898 100644 --- a/supabase/README.md +++ b/supabase/README.md @@ -1,9 +1,3 @@ # Supabase Copied and adapted from https://github.com/supabase/supabase/tree/master/docker - ---- - -## Original README - -This is a minimal Docker Compose setup for self-hosting Supabase. Follow the steps [here](https://supabase.com/docs/guides/hosting/docker) to get started. diff --git a/supabase/code/README.md b/supabase/code/README.md new file mode 100644 index 0000000..9ab215b --- /dev/null +++ b/supabase/code/README.md @@ -0,0 +1,3 @@ +# Supabase Docker + +This is a minimal Docker Compose setup for self-hosting Supabase. Follow the steps [here](https://supabase.com/docs/guides/hosting/docker) to get started. diff --git a/supabase/dev/data.sql b/supabase/code/dev/data.sql similarity index 100% rename from supabase/dev/data.sql rename to supabase/code/dev/data.sql diff --git a/supabase/dev/docker-compose.dev.yml b/supabase/code/dev/docker-compose.dev.yml similarity index 100% rename from supabase/dev/docker-compose.dev.yml rename to supabase/code/dev/docker-compose.dev.yml diff --git a/supabase/docker-compose.s3.yml b/supabase/code/docker-compose.s3.yml similarity index 100% rename from supabase/docker-compose.s3.yml rename to supabase/code/docker-compose.s3.yml diff --git a/supabase/docker-compose.yml b/supabase/code/docker-compose.yml similarity index 95% rename from supabase/docker-compose.yml rename to supabase/code/docker-compose.yml index 104dbd3..ec7fff2 100644 --- a/supabase/docker-compose.yml +++ b/supabase/code/docker-compose.yml @@ -9,6 +9,7 @@ version: "3.8" services: studio: + container_name: supabase-studio image: supabase/studio:20240701-05dfbec restart: unless-stopped healthcheck: @@ -47,10 +48,14 @@ services: # NEXT_ANALYTICS_BACKEND_PROVIDER: bigquery kong: + container_name: supabase-kong image: kong:2.8.1 restart: unless-stopped # https://unix.stackexchange.com/a/294837 entrypoint: bash -c 'eval "echo \"$$(cat ~/temp.yml)\"" > ~/kong.yml && /docker-entrypoint.sh kong docker-start' + ports: + - ${KONG_HTTP_PORT}:8000/tcp + - ${KONG_HTTPS_PORT}:8443/tcp depends_on: analytics: condition: service_healthy @@ -71,6 +76,7 @@ services: - ./volumes/api/kong.yml:/home/kong/temp.yml:ro auth: + container_name: supabase-auth image: supabase/gotrue:v2.151.0 depends_on: db: @@ -143,6 +149,7 @@ services: rest: + container_name: supabase-rest image: postgrest/postgrest:v12.2.0 depends_on: db: @@ -163,6 +170,7 @@ services: realtime: # This container name looks inconsistent but is correct because realtime constructs tenant id by parsing the subdomain + container_name: realtime-dev.supabase-realtime image: supabase/realtime:v2.29.15 depends_on: db: @@ -206,6 +214,7 @@ services: # To use S3 backed storage: docker compose -f docker-compose.yml -f docker-compose.s3.yml up storage: + container_name: supabase-storage image: supabase/storage-api:v1.0.6 depends_on: db: @@ -248,6 +257,7 @@ services: - ./volumes/storage:/var/lib/storage:z imgproxy: + container_name: supabase-imgproxy image: darthsim/imgproxy:v3.8.0 healthcheck: test: [ "CMD", "imgproxy", "health" ] @@ -263,6 +273,7 @@ services: - ./volumes/storage:/var/lib/storage:z meta: + container_name: supabase-meta image: supabase/postgres-meta:v0.83.2 depends_on: db: @@ -280,6 +291,7 @@ services: PG_META_DB_PASSWORD: ${POSTGRES_PASSWORD} functions: + container_name: supabase-edge-functions image: supabase/edge-runtime:v1.55.0 restart: unless-stopped depends_on: @@ -301,6 +313,7 @@ services: - /home/deno/functions/main analytics: + container_name: supabase-analytics image: supabase/logflare:1.4.0 healthcheck: test: [ "CMD", "curl", "http://localhost:4000/health" ] @@ -338,9 +351,12 @@ services: # Uncomment to use Big Query backend for analytics # GOOGLE_PROJECT_ID: ${GOOGLE_PROJECT_ID} # GOOGLE_PROJECT_NUMBER: ${GOOGLE_PROJECT_NUMBER} + ports: + - 4000:4000 # Comment out everything below this point if you are using an external Postgres database db: + container_name: supabase-db image: supabase/postgres:15.1.1.61 healthcheck: test: pg_isready -U postgres -h localhost @@ -357,6 +373,9 @@ services: - -c - log_min_messages=fatal # prevents Realtime polling queries from appearing in logs restart: unless-stopped + ports: + # Pass down internal port because it's set dynamically by other services + - ${POSTGRES_PORT}:${POSTGRES_PORT} environment: POSTGRES_HOST: /var/run/postgresql PGPORT: ${POSTGRES_PORT} @@ -383,6 +402,7 @@ services: - db-config:/etc/postgresql-custom vector: + container_name: supabase-vector image: timberio/vector:0.28.1-alpine healthcheck: test: diff --git a/supabase/volumes/api/kong.yml b/supabase/code/volumes/api/kong.yml similarity index 100% rename from supabase/volumes/api/kong.yml rename to supabase/code/volumes/api/kong.yml diff --git a/supabase/volumes/db/init/data.sql b/supabase/code/volumes/db/init/data.sql similarity index 100% rename from supabase/volumes/db/init/data.sql rename to supabase/code/volumes/db/init/data.sql diff --git a/supabase/volumes/db/jwt.sql b/supabase/code/volumes/db/jwt.sql similarity index 100% rename from supabase/volumes/db/jwt.sql rename to supabase/code/volumes/db/jwt.sql diff --git a/supabase/volumes/db/logs.sql b/supabase/code/volumes/db/logs.sql similarity index 100% rename from supabase/volumes/db/logs.sql rename to supabase/code/volumes/db/logs.sql diff --git a/supabase/volumes/db/realtime.sql b/supabase/code/volumes/db/realtime.sql similarity index 100% rename from supabase/volumes/db/realtime.sql rename to supabase/code/volumes/db/realtime.sql diff --git a/supabase/volumes/db/roles.sql b/supabase/code/volumes/db/roles.sql similarity index 100% rename from supabase/volumes/db/roles.sql rename to supabase/code/volumes/db/roles.sql diff --git a/supabase/volumes/db/webhooks.sql b/supabase/code/volumes/db/webhooks.sql similarity index 100% rename from supabase/volumes/db/webhooks.sql rename to supabase/code/volumes/db/webhooks.sql diff --git a/supabase/volumes/functions/hello/index.ts b/supabase/code/volumes/functions/hello/index.ts similarity index 100% rename from supabase/volumes/functions/hello/index.ts rename to supabase/code/volumes/functions/hello/index.ts diff --git a/supabase/volumes/functions/main/index.ts b/supabase/code/volumes/functions/main/index.ts similarity index 100% rename from supabase/volumes/functions/main/index.ts rename to supabase/code/volumes/functions/main/index.ts diff --git a/supabase/volumes/logs/vector.yml b/supabase/code/volumes/logs/vector.yml similarity index 100% rename from supabase/volumes/logs/vector.yml rename to supabase/code/volumes/logs/vector.yml diff --git a/supabase/repo b/supabase/repo new file mode 160000 index 0000000..a2b9f79 --- /dev/null +++ b/supabase/repo @@ -0,0 +1 @@ +Subproject commit a2b9f797918c207dd9194377b2a319f5ea626781 diff --git a/supabase/update.sh b/supabase/update.sh new file mode 100644 index 0000000..317ab09 --- /dev/null +++ b/supabase/update.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# copy files from ./repo/docker to ./code +cp -r ./repo/docker/* ./code