Back to articles
AI & Cloud

Self-Host a Lightweight Firebase Auth Replacement with SuperTokens on Rootless Docker

A technical guide to deploying SuperTokens—a lightweight, self-hosted authentication solution—on rootless Docker environments to replace Firebase Auth, optimizing performance and...

DPTCloud Engineering4 min read
Self-Host a Lightweight Firebase Auth Replacement with SuperTokens on Rootless Docker

Why Replace Firebase Auth?

Firebase Authentication is a popular choice for user authentication, but it has several limitations in self-hosted environments, especially for AI applications that require full control over infrastructure and data. Key issues include:

  • Vendor dependency: User data and authentication logic reside outside your control.
  • Cost scaling: Firebase charges based on active users, which can become expensive as your app grows.
  • Limited customization: Difficult to adapt authentication flows for internal systems or AI integrations.
  • Infrastructure constraints: Firebase does not support fully self-hosted deployment, especially on rootless Docker environments.

An ideal replacement is SuperTokens—an open-source, lightweight authentication platform that can be self-hosted and easily integrated with AI applications, APIs, or internal systems.

Introducing SuperTokens

SuperTokens is an open-source authentication solution designed to replace services like Firebase Auth, Auth0, or AWS Cognito. It offers:

  • Full self-hosting capability
  • RESTful APIs and SDKs for multiple languages (Node.js, Python, Go, etc.)
  • OAuth 2.0, JWT, and email/password authentication
  • Session management, two-factor authentication (2FA), and user management
  • Scalable deployment across environments (Docker, Kubernetes, VPS)

Notably, SuperTokens supports Docker rootless, enabling deployment without root privileges, which improves security and fits safer self-hosted environments.

Deploying SuperTokens on Rootless Docker

To deploy SuperTokens on a rootless Docker environment, ensure your system supports rootless Docker. Below is a step-by-step guide.

System Requirements

  • Docker 20.10+ (with rootless support)
  • Linux (Ubuntu 20.04+ or CentOS 8+)
  • Basic tools: curl, git, docker, docker-compose
  • No root privileges required (rootless)

Deployment Steps

1. Install Docker rootless:

curl -sSL https://get.docker.com/rootless | sh

2. Initialize Docker rootless:

dockerd-rootless-setuptool.sh install

3. Create a project directory and configure Docker Compose:

mkdir supertokens && cd supertokens
cat <<EOF > docker-compose.yml
version: '3.8'

services:
  supertokens:
    image: supertokens/supertokens:latest
    ports:
      - "3567:3567"
    environment:
      - DATABASE_URL=postgresql://supertokens:supertokens@localhost:5432/supertokens
      - JWT_SECRET=your-jwt-secret
      - ENABLE_SESSION_RENEWAL=true
    volumes:
      - ./data:/data
    restart: unless-stopped
  db:
    image: postgres:13
    environment:
      - POSTGRES_DB=supertokens
      - POSTGRES_USER=supertokens
      - POSTGRES_PASSWORD=supertokens
    ports:
      - "5432:5432"
    volumes:
      - ./db_data:/var/lib/postgresql/data
    restart: unless-stopped
EOF

4. Start the services:

docker compose up -d

Restart Docker Rootless

After installation, restart the Docker rootless service:

systemctl --user daemon-reload
systemctl --user start docker

Testing and Verification

1. Check SuperTokens health status:

curl -X GET http://localhost:3567/health

2. Access the admin interface (if available):

http://localhost:3567

3. Integrate with your AI application:

  • Use the SuperTokens SDK for your preferred language (Node.js, Python, etc.)
  • Set the authentication endpoint to http://localhost:3567
  • Test login, registration, and session validation

Troubleshooting

  • Database connection failed: Verify PostgreSQL connection and check credentials in docker-compose.yml.
  • SuperTokens fails to start: Check logs with docker compose logs supertokens.
  • Rootless Docker not working: Ensure you ran dockerd-rootless-setuptool.sh install and started the user service.
  • Port conflict: Check ports 3567 and 5432; change if needed.

References

Related infrastructure & engineering guides: High-RAM Cloud VPS for Self-Hosted LLMs & API Gateways

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478