← Back to Blog

Self-Hosting Supabase on Bare-Metal: Zero-Lockin Auth, Realtime Postgres, and Storage Architecture



Self-Hosting Supabase on Bare-Metal: Zero-Lockin Auth, Realtime Postgres, and Storage Architecture

Firebase makes starting a project easy, but as your application scales, the vendor lock-in becomes debilitating: proprietary NoSQL query limits, soaring read/write bills, and zero control over your user data. Supabase offers an open-source, relational alternative built on top of the world's most powerful database: PostgreSQL.

In this guide, I break down how we architect and harden a self-hosted Supabase cluster on a private Linux server, providing instant REST APIs, WebSockets, JWT Authentication, and S3-compatible file storage with zero monthly SaaS subscriptions.

Production Supabase Docker Compose Stack

# docker-compose.yml (Core components)
services:
 db:
 image: supabase/postgres:15.1.1.78
 restart: unless-stopped
 environment:
 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
 volumes:
 - ./volumes/db/data:/var/lib/postgresql/data
 healthcheck:
 test: ["CMD-SHELL", "pg_isready -U postgres"]
 interval: 10s

 kong:
 image: kong:2.8.1
 restart: unless-stopped
 environment:
 KONG_DATABASE: "off"
 KONG_DECLARATIVE_CONFIG: /var/lib/kong/kong.yml
 ports:
 - "8000:8000"
 - "8443:8443"

 auth:
 image: supabase/gotrue:v2.158.1
 restart: unless-stopped
 environment:
 GOTRUE_JWT_SECRET: ${JWT_SECRET}
 GOTRUE_DB_DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres

Frequently Asked Questions

Can you self-host Supabase with all features?

Yes, self-hosted Supabase includes PostgreSQL, PostgREST for instant APIs, GoTrue for JWT Auth, Realtime WebSockets, and S3-compatible storage via Docker Compose.

Why migrate from Firebase to Supabase?

Supabase eliminates Firebase's proprietary NoSQL lock-in, provides full SQL relational queries, lower latency, and 100% data sovereignty under GDPR.