This document provides instructions for developers to set up and run the Supabase service locally within the KindFi monorepo.
Ensure you have the following installed on your machine:
- Clone the Repository (if you haven't already)
git clone https://github.com/kindfi-org/kindfi.git
cd monorepo/services/supabase- Install Dependencies
bun install- Get Ready For Migrations
To create migrations, please follow this guide, it provides steps to generate migrations, ensure that they work before pushing.
- Start Supabase Services
Use the following command to start the Supabase services:
bun start # supabase startThis will start the Supabase local development environment, including the database, authentication, and storage services.
- Generate Types and Schemas
Generate the necessary types and schemas for the Supabase service:
bun gen:remote # generates what it is in the linked (remote) database
bun gen # generates what it is in local database- Environment Variables
Copy the sample environment file and update it with your configuration:
cp .env.sample .envUpdate the .env file with the KindFi Supabase project id. This is for remote type generation and to identify the local development host.
Supabase Service Role Key
The SUPABASE_SERVICE_ROLE_KEY is a critical environment variable required for server-side operations with Supabase. It grants admin-level access to your Supabase project and should be handled securely.
Obtaining the Service Role Key
- Go to your Supabase Dashboard: https://supabase.com/dashboard.
- Select the project you're working on.
- In the left sidebar, click on Settings.
- Select Data API from the settings menu.
- Locate the Service Role Key and reveal and copy it:
-
Apply (new) migrations to the local database
bun migrate # When adding new migrations file, this makes sure to apply them. -
Apply migrations by resetting local database completely
bun reset # When adding new migrations file, this makes sure to apply them by resetting from the migrations.
For more detailed instructions and advanced configurations, refer to the Supabase Local Development Guide.