# Self-host SuperTokens

> A self-hosted authentication backend with session management, social login, and passwordless, backed by Postgres.

- Page: https://levelrail.com/templates/supertokens/
- JSON: https://levelrail.com/templates/supertokens.json
- Category: Security
- Licence: Apache-2.0 (Permissive license)
- Source: https://github.com/supertokens/supertokens-core
- Upstream docs: https://supertokens.com/docs/

## Requirements
- Memory: about 256 MiB
- amd64: published, arm64: published
- Needs configuration before start: no
- Pinned image tag: 16-alpine

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| postgres | postgres | 16-alpine | none | supertokens_postgres_data -> /var/lib/postgresql/data |
| supertokens | registry.supertokens.io/supertokens/supertokens-postgresql | latest | 3567 | none |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| postgres | POSTGRES_DB | preset |
| postgres | POSTGRES_PASSWORD | generated |
| postgres | POSTGRES_USER | preset |
| supertokens | API_KEYS | generated |
| supertokens | POSTGRESQL_CONNECTION_URI | generated |

## Deploy

### CLI

```bash
levelrail-cli templates deploy supertokens --name my-supertokens
```

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://levelrail.example.com/api/v1/service-templates/supertokens/deploy
```

Create a token in the dashboard first. This one-click route deploys it as a trial app you can keep or remove.

## Questions

### Can I deploy SuperTokens on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for SuperTokens, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image postgres:16-alpine, registry.supertokens.io/supertokens/supertokens-postgresql:latest is what you deploy there.

Self-host SuperTokens, SuperTokens docker compose file, deploy SuperTokens on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
