Supabase

How to use Supabase with Docker?

Master the art of combining Supabase with Docker to simplify your dev process and deploy robust, scalable apps with ease. Discover how to make your development smoother and launch powerful solutions without a hitch.

Developer profile skeleton
a developer thinking

Overview

Using Supabase with Docker lets developers create a local setup that matches production settings. This makes team collaboration and testing smoother by keeping things consistent. A basic grasp of Docker, PostgreSQL, and Supabase is handy before getting started. Docker simplifies kicking off and handling your Supabase instance, so you can allocate resources wisely and focus on building your app. The steps ahead will show you how to set up and run Supabase on Docker, making database and backend management straightforward.

Get a Free No-Code Consultation
Meet with Will, CEO at Bootstrapped to get a Free No-Code Consultation
Book a Call
Will Hawkins
CEO at Bootstrapped

How to use Supabase with Docker?

Step 1: Install Docker

First things first, you need Docker on your machine to get Supabase up and running. Head over to the official website to download and install Docker.

Step 2: Create a Docker Network

Next, let's create a Docker network so Supabase and its buddies can chat with each other:

docker network create supabase-network

Step 3: Set Up Environment Variables

Now, we need to set up some environment variables. Create a .env file and pop in the following details:

POSTGRES_PASSWORD=your_postgres_password
POSTGRES_DB=your_database_name
ANON_KEY=your_anon_key
SERVICE_KEY=your_service_key

Make sure this file is in your project directory.

Step 4: Create a Docker Compose File

Time to create a docker-compose.yml file in your project directory. Add this content:

version: '3.8'
services:
  db:
    image: postgres:13
    container_name: supabase_db
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    networks:
      - supabase-network

  auth:
    image: supabase/gotrue:latest
    container_name: supabase_auth
    restart: unless-stopped
    environment:
      GOTRUE_DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
      GOTRUE_SITE_URL: http://localhost:8000
      GOTRUE_API_URL: http://localhost:8000/auth/v1
      GOTRUE_JWT_SECRET: ${SERVICE_KEY}
    networks:
      - supabase-network
    depends_on:
      - db

  api:
    image: supabase/postgrest:latest
    container_name: supabase_api
    restart: unless-stopped
    environment:
      PGRST_DB_URI: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
      PGRST_DB_SCHEMA: public
      PGRST_DB_ANON_ROLE: anon
      PGRST_JWT_SECRET: ${ANON_KEY}
    networks:
      - supabase-network
    depends_on:
      - db

  storage:
    image: supabase/storage-api:latest
    container_name: supabase_storage
    restart: unless-stopped
    environment:
      POSTGREST_URL: http://localhost:3000
      PGRST_JWT_SECRET: ${ANON_KEY}
      DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
    networks:
      - supabase-network
    depends_on:
      - db

  realtime:
    image: supabase/realtime:latest
    container_name: supabase_realtime
    restart: unless-stopped
    environment:
      DB_HOST: db
      DB_PORT: 5432
      DB_NAME: ${POSTGRES_DB}
      DB_USER: postgres
      DB_PASSWORD: ${POSTGRES_PASSWORD}
      REALTIME_PORT: 4000
    networks:
      - supabase-network
    depends_on:
      - db

networks:
  supabase-network:
    driver: bridge

This setup includes PostgreSQL, GoTrue, PostgREST, Storage API, and Realtime services for Supabase.

Step 5: Start the Docker Containers

Navigate to your project directory and fire up all the services with Docker Compose:

docker-compose up -d

This command will build and start all the containers in detached mode. Easy peasy!

Step 6: Verify the Services

Let's make sure everything is running smoothly. Check the status of the containers:

docker-compose ps

You should see that all services are "Up". If not, well, time to do some troubleshooting!

Step 7: Interact with Supabase

Now, let's interact with Supabase:

  • PostgreSQL: Use a client like psql or a GUI like pgAdmin to access your PostgreSQL instance.
  • GoTrue (Authentication): Access it via http://localhost:8000/auth/v1.
  • Realtime: Check Realtime subscriptions at http://localhost:4000.

Make sure you're hitting the right endpoints and managing your containers properly.

Explore more Supabase tutorials

Complete Guide to Supabase: Tutorials, Tips, and Best Practices

Explore our Supabase tutorials directory - an essential resource for learning how to create, deploy and manage robust server-side applications with ease and efficiency.

Why are companies choosing Bootstrapped?

40-60%

Faster with no-code

Nocode tools allow us to develop and deploy your new application 40-60% faster than regular app development methods.

90 days

From idea to MVP

Save time, money, and energy with an optimized hiring process. Access a pool of experts who are sourced, vetted, and matched to meet your precise requirements.

1 283 apps

built by our developers

With the Bootstrapped platform, managing projects and developers has never been easier.

hero graphic

Our capabilities

Bootstrapped offers a comprehensive suite of capabilities tailored for startups. Our expertise spans web and mobile app development, utilizing the latest technologies to ensure high performance and scalability. The team excels in creating intuitive user interfaces and seamless user experiences. We employ agile methodologies for flexible and efficient project management, ensuring timely delivery and adaptability to changing requirements. Additionally, Bootstrapped provides continuous support and maintenance, helping startups grow and evolve their digital products. Our services are designed to be affordable and high-quality, making them an ideal partner for new ventures.

Engineered for you

1

Fast Development: Bootstrapped specializes in helping startup founders build web and mobile apps quickly, ensuring a fast go-to-market strategy.

2

Tailored Solutions: The company offers customized app development, adapting to specific business needs and goals, which ensures your app stands out in the competitive market.

3

Expert Team: With a team of experienced developers and designers, Bootstrapped ensures high-quality, reliable, and scalable app solutions.

4

Affordable Pricing: Ideal for startups, Bootstrapped offers cost-effective development services without compromising on quality.

5

Supportive Partnership: Beyond development, Bootstrapped provides ongoing support and consultation, fostering long-term success for your startup.

6

Agile Methodology: Utilizing agile development practices, Bootstrapped ensures flexibility, iterative progress, and swift adaptation to changes, enhancing project success.

Yes, if you can dream it, we can build it.