Skip to content

Instantly share code, notes, and snippets.

@ethicnology
Created August 4, 2024 20:03
Show Gist options
  • Save ethicnology/9ef6639ba4d170221378b40c2af5ccb2 to your computer and use it in GitHub Desktop.
Save ethicnology/9ef6639ba4d170221378b40c2af5ccb2 to your computer and use it in GitHub Desktop.
I like supabase but they don't care so much about self-hosted users.

Supabase self-hosted

Setup

Clone docker repository ONLY

mkdir supabase-for-my-app && cd "$_"

git clone -n --depth=1 --filter=tree:0 https://github.com/supabase/supabase .

git sparse-checkout set --no-cone docker

git checkout

.env

Copy .env from .env.example

cd docker

cp .env.example .env

Edit environment variables

nano .env

Rename docker-compose to compose

mv docker-compose.yml compose.yml
mv docker-compose.s3.yml compose.s3.yml

Download images and create containers

Builds, (re)creates, and starts containers

docker compose -f compose.yml -f compose.s3.yml up --detach # or up -d

Remove containers and networks (optionally images and volumes as well)

docker compose -f compose.yml -f compose.s3.yml down

Post-install (not sure if it's still recommended)

### Destroy analytics to transition to postgres self hosted solution without other data loss

# Enter the container and use your .env POSTGRES_PASSWORD value to login
docker exec -it $(docker ps | grep supabase-db | awk '{print $1}') psql -U supabase_admin --password
# Drop all the data in the _analytics schema
DROP PUBLICATION logflare_pub; DROP SCHEMA _analytics CASCADE; CREATE SCHEMA _analytics;\q
# Drop the analytics container
docker rm supabase-analytics --force

Usage

docker compose

Start

docker compose -f compose.yml -f compose.s3.yml start

Stop

docker compose -f compose.yml -f compose.s3.yml stop

Logs

docker compose -f compose.yml -f compose.s3.yml logs

Studio

You should be able to connect to the web interface exposed on port 3000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment