Supabase Docker with Traefik

Note: this setup is unnofficial. It is supported by the Supabase community only.

This guide is covering a self-hosted Supabase setup with Traefik as a reverse proxy.

Please make sure you read the self-hosting guide.

Not using Traefik yet? Getting started from scratch

Goal

  • Super simple to install
  • Run Supabase on bare metal (maximum privacy) - dedicated/root server or VPS
  • Uses Let's Encrypt certificates
  • Uses pgAdmin to provide at least some interface to Supabase on the self-hosted Supabase instance

Requirements/Assumptions

  • Machine with Linux and SSH access
  • Installed git, docker and docker-compose
  • Access to a Traefik supported DNS providers API: see this list
  • Traefik isn't used yet
  • Ports 443 and 80 aren't used yet

Getting started

Traefik is a proxy that gets its configuration from the docker-compose labels. The labels needed for Supabase are already provided in the docker-compose.yml.

1. Clone the Supabase repository

git clone https://github.com/supabase-community/supabase-traefik
cd supabase-traefik

2. Setup Traefik

2.1 Copy .env.example to .env
cp .env.example .env
2.2 Add your DNS provider for automatic/easy certificate generation

Create traefik/.env and add your Let's Encrypt contact email address as well as your provider. This example is using PowerDNS.

# pdns is for PowerDNS - a self-hosted DNS server
ACME_DNS_CHALLENGE_PROVIDER=pdns
ACME_EMAIL=letsencrypt@example.com

# DNS provider specific config for pdns
PDNS_API_KEY=SOME API KEY
PDNS_API_URL=https://some.url.to.your.pdns.server

Learn more about the DNS challenge

Learn more about available DNS providers (there are MANY)

2.3 Add the DNS provider specific details

Edit the traefik/docker-compose.yml environment section to be compatible with your DNS provider. This example is using PowerDNS.

PDNS_API_KEY and PDNS_API_URL are acting as variables between the .env and the docker-compose file.

environment:
    - PDNS_API_KEY=${PDNS_API_KEY}
    - PDNS_API_URL=${PDNS_API_URL}
2.4 Start Traefik

Run following command in traefik/ to start Traefik detached docker-compose up -d

3. Change the directory into the supabase-traefik folder

cd ..

4. Edit the .env file and insert your own environment variables: passwords etc.

4.1. Change your hostname
  • Change the SUPABASE_HOSTNAME to the hostname/subdomain you want to use for Supabase
TRAEFIK_NETWORK=rp
SUPABASE_HOSTNAME=supabase.example.com

5. Start the Supabase containers with docker-compose

Run following command to start the Supabase containers detached docker-compose up -d

6. Test the endpoints below

Use Supabase with an existing Traefik setup

You can also use the docker-compose.yml with an existing Traefik setup. Just ignore the traefik folder and customize the .env file and docker-compose.yml as it fits your setup. Run docker-compose up -d and check if all endpoints below are working. Use them as described in the docker/readme.md.

Endpoints

Kong

supabase.example.com/

GoTrue

supabase.example.com/auth/v1/

you can test GoTrue with

supabase.example.com/auth/v1/settings

as the default path returns 404

PostgREST

supabase.example.com/rest/v1/

Realtime

supabase.example.com/realtime/v1/

Postgres

The Postgres database is only available internally via the db docker network. You can however access it through pgAdmin.

supabase.example.com/pgadmin/