# Self-host Dex

> OpenID Connect identity provider that fronts other identity sources. The install form carries config.yaml as an editable file, so it starts with a local database and the issuer address you choose.

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

## Requirements
- Memory: about 128 MiB
- amd64: unknown, arm64: unknown
- Needs configuration before start: no
- Pinned image tag: v2.46.1

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| dex | ghcr.io/dexidp/dex | v2.46.1 | 5556 | data -> /var/dex |

## Deploy

### CLI

```bash
levelrail-cli templates install dex --name my-dex
```

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain dex=app.example.com.

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/dex/install \
  -d '{
    "name": "my-dex"
  }'
```

Create a token in the dashboard first. Name, env and domains are the request fields.

## First run
1. Open the address followed by /dex/.well-known/openid-configuration to see the discovery document, then edit the config file setting to add connectors and static clients.

## Questions

### Can I deploy Dex 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 Dex, 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 ghcr.io/dexidp/dex:v2.46.1 is what you deploy there.

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