guide

Docker (Self-Hosted)

Run Postbase anywhere with Docker Compose — the base every hosted option builds on.

Published: September 6, 2026Updated: September 6, 2026

Postbase is a self-hosted auth and database platform for Next.js. Drop it into your stack, configure 25+ auth providers from a dashboard, and connect your app with a single SDK call. Think self-hosted Supabase or Clerk — you own the data, you control the infra.

About Self-Hosting with Docker

The fastest way to run Postbase anywhere — your own server, a VPS, or locally — is Docker Compose. This is also the base every cloud template above builds on: each provider just runs the same Dockerfile.railway image behind their own managed Postgres.

Common Use Cases

  • Add auth to a Next.js app — enable email/password, magic links, or any of 25+ OAuth providers (GitHub, Google, Discord, and more) from the dashboard without writing auth code

  • Self-host your user database — store users, sessions, and OAuth accounts in your own Postgres instance with full SQL access via the built-in editor

  • Manage files and storage — connect Amazon S3, Cloudflare R2, Backblaze B2, or any S3-compatible bucket per-project from the dashboard

Quick Start

1. Clone & configure

git clone https://github.com/harshalone/postbase
cd postbase
cp .env.example .env

Generate and set a secret in .env:

openssl rand -base64 32   # paste output as NEXTAUTH_SECRET

2. Start the services

docker compose up -d

This starts PostgreSQL on port 5432 and the Postbase app on port 3000.

3. Run database migrations

cd apps/web
pnpm install
pnpm db:push

4. Open the dashboard

Visit http://localhost:3000/dashboard:

  • Create a project → get your anon key and service_role key

  • Go to Auth Providers → enable the providers you want, paste in OAuth credentials

  • Copy your keys from the API Keys tab

Local Development

For development you don’t need to rebuild Docker on every change. Run only the infrastructure (PostgreSQL) in Docker and the Next.js app locally with hot reload — the included dev.sh script handles this:

./dev.sh           # start infra + app (hot reload)
./dev.sh --rebuild # rebuild containers
./dev.sh --reset   # wipe data and restart clean

Or manually:

pnpm infra:up   # start Postgres only
pnpm db:push    # first time only — run migrations
pnpm dev        # Next.js dev server with hot reload
  • pnpm infra:up: Start postgres

  • pnpm infra:down: Stop postgres (data is preserved)

  • pnpm infra:logs: Tail infrastructure logs

  • pnpm dev: Start Next.js dev server

  • pnpm db:push: Push schema changes to the database

  • pnpm db:studio: Open Drizzle Studio (visual DB browser)

For production, use the full Docker Compose stack (includes the app container): docker compose up -d.

Environment Variables

  • DATABASE_URL: PostgreSQL connection string — default postgresql://postbase:postbase@localhost:5432/postbase

  • NEXTAUTH_SECRET: Secret for signing tokens — required, no default

  • NEXTAUTH_URL: Public URL of your Postbase instance — default http://localhost:3000


Why Self-Host with Docker?

No managed-platform lock-in — run Postbase on any machine that can run Docker, including your own bare-metal server. This is the base every hosted deploy option above is built from.