Firebase, an extensive platform by Google, empowers developers with a complete solution for crafting mobile and web applications. This comprehensive toolkit equips them to develop and deploy applications across iOS, Android, the web, C++, and Unity environments. Praised for its user-friendly nature, Firebase is lauded for its simplicity, seamless integration capabilities, and its ability to harmonize with a wide array of other tools.

Supabase stands as an open-source platform that seamlessly combines the attributes of a real-time database and a serverless architecture. In direct competition with Firebase, Supabase presents an extensive array of user-friendly backend features. Notably, it excels in its remarkable adaptability and scalability, rendering it an optimal choice to address diverse requirements.

The features offered by Supabase include:

  • Real-time Database: The real-time database offered by Supabase is powered by PostgreSQL. This allows developers to build applications that are able to synchronize data across devices just like Firebase
  • Authentication: allows users to easily handle user registration, login, and access control. There are several supported authentication methods like email/password, social media logins etc.
  • Real-time Pub/Sub: user can subscribe to databases and receive instantaneous updates triggered by data modifications.
  • RESTful APIs: Automated generation of RESTful APIs for seamless frontend interaction.
  • Custom Serverless Functions: Empowerment to build custom serverless functions responding to specific events.
  • Storage: Inclusion of storage capabilities for user-generated content such as images and files.
  • Scalability: It provides scalability tailored to application requirements, catering to projects of all sizes.

In this tutorial, we will learn how to run the Supabase Firebase alternative in Docker Container.

1. Install Docker and Docker Compose

The first step to do is to ensure that both Docker and Docker-compose have been installed. To achieve that, follow our dedicated guides below:

Install Docker on Linux using the aid here:

Install Docker Compose by following the steps in this guide:

Ensure that your system user is added to the Docker group:

sudo usermod -aG docker $USER
newgrp docker

2. Configure the Supabase Container

Now, clone the Supabase repository using the command:

git clone --depth 1 https://github.com/supabase/supabase

Navigate into the directory:

cd supabase/docker

Create the environment variables file:

cp .env.example .env

Now you can modify the variables as desired.

vim .env

In the file, you can:

  • Update the Secrets: There are several secrets in the file, replace them with your own:
    • POSTGRES_PASSWORD: the password for the Postgres role.
    • JWT_SECRET: used by PostgREST and GoTrue, among others.(at least 32 characters).
    • ANON_KEY: replace with an anon key
    • SERVICE_ROLE_KEY: replace with a service key
    • SITE_URL: the base URL of your site.
    • SMTP_*: mail server credentials. You can use any SMTP server.

3. Run Supabase Firebase in Docker Container

Once the changes have been made to the config, save it and run the containers using the command below:

docker compose up -d

Sample output:

[+] Running 11/11
 ✔ Network docker_default                    Created                                     0.1s 
 ✔ Container supabase-db                     Healthy                                    14.4s 
 ✔ Container supabase-edge-functions         Star...                                     1.9s 
 ✔ Container supabase-imgproxy               Started                                     1.9s 
 ✔ Container supabase-studio                 Started                                     2.2s 
 ✔ Container supabase-kong                   Started                                     2.3s 
 ✔ Container supabase-auth                   Started                                    13.8s 
 ✔ Container supabase-rest                   Started                                    13.4s 
 ✔ Container realtime-dev.supabase-realtime  Started                                    13.8s 
 ✔ Container supabase-meta                   Started                                    13.8s 
 ✔ Container supabase-storage                Started                                    14.7s

Check if the containers are running:

$ docker ps
CONTAINER ID   IMAGE                            COMMAND                   CREATED         STATUS                        PORTS                                                                                                      NAMES
e3e698d374f6   supabase/storage-api:v0.40.4     "docker-entrypoint.s…"    2 minutes ago   Up About a minute (healthy)   5000/tcp                                                                                                   supabase-storage
7f3899d50c8c   supabase/realtime:v2.10.1        "/usr/bin/tini -s -g…"    2 minutes ago   Up About a minute (healthy)                                                                                                              realtime-dev.supabase-realtime
ec551a5187d8   postgrest/postgrest:v11.1.0      "/bin/postgrest"          2 minutes ago   Up About a minute             3000/tcp                                                                                                   supabase-rest
44932a21ac35   supabase/gotrue:v2.62.1          "gotrue"                  2 minutes ago   Up About a minute (healthy)                                                                                                              supabase-auth
5670a6dc6664   supabase/postgres-meta:v0.66.3   "docker-entrypoint.s…"    2 minutes ago   Up About a minute (healthy)   8080/tcp                                                                                                   supabase-meta
043bf7deb31a   kong:2.8.1                       "bash -c 'eval \"echo…"   2 minutes ago   Up 2 minutes (healthy)        0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 8001/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp, 8444/tcp   supabase-kong
d48b15c9d45b   supabase/edge-runtime:v1.6.6     "edge-runtime start …"    2 minutes ago   Up 2 minutes                                                                                                                             supabase-edge-functions
bfcd3810aef7   supabase/studio:v0.23.06         "docker-entrypoint.s…"    2 minutes ago   Up 2 minutes (healthy)        0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                                                  supabase-studio
d6af8c0f0029   darthsim/imgproxy:v3.8.0         "imgproxy"                2 minutes ago   Up 2 minutes (healthy)        8080/tcp                                                                                                   supabase-imgproxy
c8c80ac516b0   supabase/postgres:15.1.0.90      "docker-entrypoint.s…"    2 minutes ago   Up 2 minutes (healthy)        0.0.0.0:5432->5432/tcp, :::5432->5432/tcp                                                                  supabase-db

4. Access and Use Supabase

After starting the containers, the Supabase will be available on port 3000. You can now access it using the URL http://domain_name:3000 or http://localhost:3000 as set in your variables file.

Running Supabase Firebase alternative in Docker Container 6

Once here, you can connect to the available default project.

Running Supabase Firebase alternative in Docker Container 7

You are now ready to get started. You can access the SQL editor and run your queries.

Running Supabase Firebase alternative in Docker Container 3

Get access to the database:

Running Supabase Firebase alternative in Docker Container 8

Manage authentication.

Running Supabase Firebase alternative in Docker Container 2

You can add a user as shown:

Running Supabase Firebase alternative in Docker Container 1

You can also create a user auth with email and password using the command with the syntax:

curl -X POST 'http://localhost:8000/auth/v1/signup' \
-H "apikey: Supabase_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
  "email": "[email protected]",
  "password": "Passw0rd!"
}'

Once created, the user will appear as shown:

Running Supabase Firebase alternative in Docker Container 4

Create and manage buckets.

Running Supabase Firebase alternative in Docker Container 5

That is it for now! We have walked through how to run Supabase – Firebase alternative in Docker Container. Now you have an open-source Firebase alternative with various tools required to build and ship Android, iOS, the web, C++ etc. I hope this was significant.

See more:

LEAVE A REPLY

Please enter your comment!
Please enter your name here