# Self-host Directus

> An open-source headless CMS and instant REST/GraphQL API layer over your own database.

- Page: https://levelrail.com/templates/directus/
- JSON: https://levelrail.com/templates/directus.json
- Category: Developer Tools
- Licence: BUSL-1.1 (Source available)
- Source: https://github.com/directus/directus
- Upstream docs: https://docs.directus.io

## Requirements
- Memory: about 512 MiB
- amd64: published, arm64: tested
- Needs configuration before start: no
- Pinned image tag: 11

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| db | postgres | 16-alpine | none | directus_db_data -> /var/lib/postgresql/data |
| directus | directus/directus | 11 | 8055 | directus_uploads -> /directus/uploads |
| redis | redis | 7-alpine | none | directus_redis_data -> /data |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| db | POSTGRES_DB | preset |
| db | POSTGRES_PASSWORD | generated |
| db | POSTGRES_USER | preset |
| directus | ADMIN_EMAIL | preset |
| directus | ADMIN_PASSWORD | generated |
| directus | CACHE_ENABLED | preset |
| directus | CACHE_STORE | preset |
| directus | DB_CLIENT | preset |
| directus | DB_DATABASE | preset |
| directus | DB_HOST | preset |
| directus | DB_PASSWORD | generated |
| directus | DB_PORT | preset |
| directus | DB_USER | preset |
| directus | KEY | generated |
| directus | REDIS | preset |
| directus | SECRET | generated |

## Deploy

### CLI

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

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://levelrail.example.com/api/v1/service-templates/directus/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 Directus on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list has an entry with the id directus for this app, so check that entry as well. Dokku deploys container images with its own commands, so the pinned image postgres:16-alpine, directus/directus:11, redis:7-alpine is what you deploy there.

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