Skip to content

drizzle-team/fastabase

Repository files navigation

Fastabase

Fastabase is a solution to self-host Supabase on AWS and use PlanetScale Postgres as the database provider.

Overview

Fastabase is built using several components:

  • SST to orchestrate the deployment to AWS
  • OpenNext to deploy Supabase Studio as a serverless component
  • Supabase components like Storage, Auth, etc.

Architecture

diagram

  • Most of the Supabase components are deployed as Docker containers to ECS Fargate
  • Entrypoint for Supabase API is an Application Load Balancer behind a CloudFront distribution
  • Amazon SES SMTP servers are used for sending emails
  • Supabase Studio is deployed using OpenNext
    • Studio is protected by user/password auth via a CloudFront function

Prerequisites

  1. Install Node.js 22 and pnpm
  2. PlanetScale:
    1. Go to Cluster configuration -> Extensions and enable pg_stat_statements and pg_cron extensions.
    2. Go to Cluster configuration -> Parameters and set max_client_conn to at least 50.

Deployment

  1. Clone this repository and cd into it.

  2. Init Git submodules:

    git submodule update --init
  3. Create a config.yaml configuration file:

    cp config.yaml.example config.yaml
  4. Fill in the values in config.yaml.

  5. Install the dependencies:

    pnpm i
  6. Set up the AWS credentials:

    export AWS_PROFILE=<profile>

    [!TIP] To learn how to set up the AWS credentials in your terminal, please refer to the AWS documentation.

  7. Run the deployment:

    pnpm run deploy

    [!WARNING] SST deploys resources to a certain stage. This allows you to deploy multiple copies of your app in the same account.

    By default, the stage name is set to the username on your local machine. You can specify a different stage name with pnpm run deploy --stage <name>.

Removal

To remove a deployed Fastabase instance, run:

pnpm run remove

Note

If you used a non-default stage name during deployment, you also need to provide it here with pnpm run remove --stage <name>.

Roadmap

Core Supabase components

  • Auth
  • Storage
  • PostgREST
  • Imgproxy
  • Pg-meta
  • Logs
  • Realtime
  • Edge functions

Customization

  • OpenAI API key
  • External auth providers
  • Custom domain

Improvements

  • Show real DB credentials in the Studio's "Connect" dialog (currently hardcoded to localhost in Supabase's codebase)

Notes

  • By default, Amazon SES is in sandbox mode, which means you can only send emails from and to verified email addresses. Make sure to exit the sandbox mode before sending emails to real users.

  • Logs and Realtime components currently do not support connecting to Postgres with SSL, so they are connecting to PlanetScale via Envoy that serves as an SSL proxy. Envoy is deployed as an ECS service. Once the SSL support is implemented in Logs and Realtime components, the Envoy service will be removed.

About

A solution to self-host Supabase on AWS and use PlanetScale Postgres as the database provider.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published