Tired of vendor lock-in and monthly subscription fees for your backend services? Meet Supabase – the open-source powerhouse that’s revolutionizing how developers build modern applications. As someone who’s been wrestling with Firebase limitations for years, I can tell you that Supabase feels like a breath of fresh air in the backend-as-a-service world.
What Makes Supabase Special?
Supabase isn’t just another Firebase clone – it’s a complete backend platform built on enterprise-grade open-source tools. Think of it as your Swiss Army knife for backend development, combining the best of PostgreSQL’s reliability with modern real-time capabilities.
Core Features That’ll Make You Smile:
- PostgreSQL Database: Every project gets a full PostgreSQL database with vector support for AI applications
- Real-time Subscriptions: Listen to database changes through WebSockets without writing complex code
- Authentication System: Email, social, phone, and passwordless login options out of the box
- File Storage: Store and serve files with built-in CDN and image transformations
- Edge Functions: Deploy TypeScript functions globally with NPM compatibility
- Auto-generated APIs: RESTful and GraphQL APIs created automatically from your database schema
What sets Supabase apart from Firebase is its commitment to open standards and SQL. While Firebase locks you into NoSQL document databases, Supabase gives you the full power of PostgreSQL with complex queries, relationships, and data integrity. Plus, you can self-host it entirely, keeping your data under your control.
Why Self-Host Supabase?
Before we dive into the technical stuff, let me share why self-hosting Supabase makes sense:
- Data Sovereignty: Your sensitive data stays on your infrastructure
- Cost Optimization: Avoid recurring subscription fees for large-scale projects
- Customization: Fine-tune every aspect of your backend
- Learning Experience: Understand backend architecture at a deeper level
- Regulatory Compliance: Meet specific industry requirements
Prerequisites
Let’s make sure you have everything needed before we start:
- Ubuntu 18.04 or later (20.04 LTS recommended for stability)
- User account with
sudo
privileges - At least 4GB RAM and 2 CPU cores for optimal performance
- Basic terminal familiarity
Step 1: Install Docker Engine
Docker is the foundation that makes Supabase self-hosting possible. Here’s how to get it running on Ubuntu:
# Update your package repository
sudo apt update
# Install prerequisite packages
sudo apt install -y ca-certificates curl git
# Create directory for Docker's GPG key
sudo install -m 0755 -d /etc/apt/keyrings
# Add Docker's official GPG key
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add Docker repository to Ubuntu
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Enable Docker at startup and test the installation:
# Start Docker and enable at boot
sudo systemctl enable docker --now
# Test Docker installation
sudo docker run hello-world
Pro Tip: Add your user to the Docker group to avoid typing sudo
repeatedly:
sudo usermod -aG docker $USER
newgrp docker
Step 2: Install Docker Compose
Modern Docker installations include Docker Compose as a plugin, but let’s verify it’s working:
# Check if Docker Compose is available
docker compose version
If you see version information, you’re good to go! If not, install the standalone version:
# Download Docker Compose binary
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Make it executable
sudo chmod +x /usr/local/bin/docker-compose
# Verify installation
docker-compose --version
Step 3: Download and Set Up Supabase
Now comes the exciting part – getting Supabase ready to run:
# Clone the official Supabase repository
git clone --depth 1 https://github.com/supabase/supabase
# Create your project directory
mkdir supabase-project
# Copy Docker configuration files
cp -rf supabase/docker/* supabase-project/
# Copy environment variables template
cp supabase/docker/.env.example supabase-project/.env
# Navigate to your project directory
cd supabase-project
Step 4: Configure Environment Variables
This is where many people stumble, so let’s get it right. Open the .env
file and customize these critical settings:
nano .env
Essential variables to change:
# Database Configuration
POSTGRES_PASSWORD=your_super_secure_postgres_password
POSTGRES_DB=supabase_db
# JWT Configuration (generate a strong 40-character secret)
JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters
# API Keys (you'll generate these after initial setup)
ANON_KEY=your_anon_key_here
SERVICE_ROLE_KEY=your_service_role_key_here
# Dashboard Authentication
DASHBOARD_USERNAME=your_admin_username
DASHBOARD_PASSWORD=your_secure_dashboard_password
# Site Configuration
SITE_URL=http://localhost:8000
SUPABASE_PUBLIC_URL=http://localhost:8000
# Pooler Configuration
POOLER_TENANT_ID=your-tenant-id
Security Warning: Never use the default passwords in production. Generate strong, unique passwords for each service.
Step 5: Generate API Keys
Supabase uses JWT tokens for API authentication. You’ll need to generate proper anon
and service_role
keys:
- Visit jwt.io
- Use your
JWT_SECRET
from the.env
file - Create two tokens with different payloads:
For the anon
key:
{
"role": "anon",
"iss": "supabase"
}
For the service_role
key:
{
"role": "service_role",
"iss": "supabase"
}
Update your .env
file with the generated tokens.
Step 6: Launch Supabase
Time to bring everything to life:
# Pull the latest Docker images
docker compose pull
# Start all services in detached mode
docker compose up -d
Check if everything is running properly:
# View running containers
docker compose ps
You should see all services with a status of running (healthy)
. If any service shows as created
but not running
, start it manually:
docker compose start <service-name>
Step 7: Access Supabase Studio
The moment you’ve been waiting for! Open your browser and navigate to http://localhost:8000
.
You’ll be prompted for credentials:
- Username: The value you set for
DASHBOARD_USERNAME
- Password: The value you set for
DASHBOARD_PASSWORD
What you’ll see in Supabase Studio:
- Table Editor: Create and manage database tables visually
- SQL Editor: Write and execute custom queries
- Authentication: Manage users and authentication settings
- Storage: Handle file uploads and management
- Edge Functions: Deploy and manage serverless functions
Step 8: Test Your Setup
Let’s verify everything works by creating a simple table:
- In Supabase Studio, go to the Table Editor
- Click New Table
- Create a table called
tasks
with these columns:id
(int8, primary key)title
(text)completed
(bool, default false)created_at
(timestamptz, default now())
- Insert a test record and verify it appears
Test the API endpoints:
- REST API:
http://localhost:8000/rest/v1/
- Auth API:
http://localhost:8000/auth/v1/
- Storage API:
http://localhost:8000/storage/v1/
Common Issues and Solutions
Container Exits Immediately
If you’re using rootless Docker, edit your .env
file and set:
DOCKER_SOCKET_LOCATION=/run/user/1000/docker.sock
Port Conflicts
If port 8000 is already in use, modify the docker-compose.yml
file:
ports:
- "8001:8000" # Changed from 8000:8000
Database Connection Issues
Ensure your PostgreSQL password in the .env
file matches across all services. Check the logs:
docker compose logs db
Permission Denied Errors
This usually means your API keys are incorrect or missing. Regenerate them following Step 5 and restart services:
docker compose down
docker compose up -d
Studio Not Loading
Check if the Studio service is healthy:
docker compose ps studio
If it’s not running, restart it:
docker compose restart studio --no-deps
Updating Your Services
Keep your Supabase installation secure and up-to-date:
# Pull latest images
docker compose pull
# Restart with new versions
docker compose down
docker compose up -d
Pro Tip: Subscribe to Supabase’s GitHub releases to stay informed about security patches and new features.
What’s Next?
Now that you have Supabase running locally, here are some next steps to explore:
- Set up SMTP: Configure email authentication using your preferred email service
- Enable S3 Storage: Use external object storage for better scalability
- Configure Custom Domains: Set up SSL certificates for production deployment
- Explore Edge Functions: Deploy TypeScript functions for custom business logic
- Set up Monitoring: Use tools like Grafana for performance monitoring
Final Thoughts
Self-hosting Supabase with Docker Compose gives you the best of both worlds – the developer experience of a modern BaaS platform with complete control over your infrastructure. While the initial setup requires some technical knowledge, the long-term benefits of data sovereignty, cost savings, and customization make it worthwhile for serious projects.
Remember to regularly backup your data, keep your services updated, and never use default passwords in production. With proper maintenance, your self-hosted Supabase instance can serve as a rock-solid foundation for your applications.
Happy building!