Deploying Supabase with Docker Compose
Supabase Docker Compose
In the world of modern web and mobile app development, having a robust backend service is crucial. Supabase has emerged as a powerful open-source alternative to Firebase, offering developers a suite of tools to build scalable applications without the complexity of managing backend infrastructure. Today, I'll show you how to self-host Supabase using Docker Compose with a zero-configuration approach.
What is Supabase?
Supabase is an open-source Firebase alternative that provides developers with all the backend services needed to build a product. It combines several powerful tools into a single, easy-to-use platform:
Outstanding Features
PostgreSQL Database: At its core, Supabase is powered by PostgreSQL, one of the most advanced open-source relational databases.
Authentication: Built-in authentication system with support for email/password, magic links, OAuth providers (Google, GitHub, etc.), and phone auth.
Auto-generated APIs: RESTful and real-time APIs are automatically generated based on your database schema.
Real-time Subscriptions: Listen to database changes in real-time using WebSockets.
Storage: Store and serve large files like images, videos, and documents.
Edge Functions: Write and deploy serverless functions.
Vector Support: Built-in support for AI vector embeddings and similarity search.
Database Webhooks: Trigger external services when database changes occur.
The best part? All of these features are open-source and can be self-hosted!
Self-Hosting Supabase with Docker Compose
While Supabase offers a hosted platform, self-hosting gives you complete control over your data and infrastructure. Let's see how to deploy Supabase locally or on your own server using my zero-config Docker Compose setup.
Github: https://github.com/minhng92/supabase-docker-compose
Prerequisites
- Docker and Docker Compose installed on your system
- Basic understanding of terminal/command line
- Git (optional, for cloning the repository)
Quick Installation
To quickly install Supabase using Docker Compose, run:
curl -s https://raw.githubusercontent.com/minhng92/supabase-docker-compose/master/run.sh | bash -s my-supabase
Replace my-supabase
with your desired destination folder.
Then open Supabase Studio at http://localhost:8000 and log in with the following credentials:
- Username: supabase
- Password: minhng.info (default password)
Manual Installation
If you prefer a more manual approach, follow these steps:
Step 1: Clone the Repository
Start by cloning my repository which contains the pre-configured Docker Compose setup:
git clone https://github.com/minhng92/supabase-docker-compose.git
cd supabase-docker-compose
Step 2: Configure Environment Variables (Optional)
The repository is designed with a "zero-config" philosophy, so you can start without modifying any configuration. However, you may want to customize some settings:
# Edit the .env file with your preferred editor
nano .env
In the .env
file, you can customize things like:
- Database credentials
- JWT secrets
- API keys
- Storage settings Otherwise, the default values (eg. minhng.info) will be used.
Step 3: Deploy Supabase
Now, simply run Docker Compose to start all Supabase services:
docker-compose up -d
This command will:
- Pull all necessary Docker images
- Create required networks and volumes
- Start all Supabase services in the correct order
- Run in detached mode (-d flag), so you can continue using your terminal
Step 4: Access Supabase
Once all services are running, you can access:
- Supabase Studio (Dashboard): http://localhost:8000 (U/P: supabase/minhng.info)
- API Endpoints: http://localhost:8000/rest/v1/
- Authentication API: http://localhost:8000/auth/v1/
Step 5: Using Supabase in Your Application
To connect your application to your self-hosted Supabase instance, you'll need:
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = 'http://localhost:8000'
const supabaseKey = 'your-anon-key-from-api-settings'
const supabase = createClient(supabaseUrl, supabaseKey)
Managing Your Deployment
Some useful commands for managing your deployment:
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Stop and remove volumes (will delete all data)
docker-compose down -v
# Restart a specific service
docker-compose restart postgres
Benefits of Self-Hosting
Self-hosting Supabase gives you several advantages:
- Complete Data Ownership: Your data stays on your infrastructure
- Customization: Ability to modify services as needed
- Cost Control: Potentially lower costs for high-usage applications
- Privacy Compliance: Easier to comply with regulations like GDPR
- No Vendor Lock-in: Freedom to migrate or change your setup
Conclusion
Self-hosting Supabase with Docker Compose provides a flexible and powerful way to leverage all the features of Supabase while maintaining control over your infrastructure. My zero-config approach makes it accessible even for developers who might not be infrastructure experts.
The repository at github.com/minhng92/supabase-docker-compose aims to simplify this process, allowing you to focus on building your application rather than configuring backend services.
Whether you're building a personal project, a startup MVP, or an enterprise application, self-hosting Supabase can be an excellent option for your backend needs.
Happy coding!
More docker-compose files for you:
- Deploying Supabase with Docker Compose
- Docker for Zabbix
- Docker compose for Redis
- Docker Compose for Traefik (reverse proxy HTTP)
- Set up Nginx reverse proxy HTTP/HTTPS with Docker Compose
- Docker compose for VSCode server
- Set up Pytorch Env with Docker within 1 Minute
- Docker Compose for Jekyll
- Docker Compose for Odoo 10
- Docker Compose for Odoo 11
- Docker Compose for Odoo 12
- Docker Compose for Odoo 13
- Docker Compose for Odoo 14
- Docker Compose for Odoo 15
- Docker Compose for Odoo 16
- Docker Compose for Odoo 17
- Docker Compose for Odoo 18