Skip to main content
[ PIER ]

Directus with PostgreSQL

Directus headless CMS — wired to PostgreSQL out of the box.

Service #cms#headless#api#graphql#postgresql

Directus (the open-source headless CMS and data platform) paired with a dedicated PostgreSQL backend in one Pier stack. Pre-wired env vars, persistent volumes, ready for production multi-user content teams or any use case where SQLite is no longer enough.

Deploy with Pier

  1. 1 Open the Pier dashboard and click Add service.
  2. 2 Pick Directus with PostgreSQL from the template list.
  3. 3 Choose the version, set a service name, and Pier provisions the container, storage, and ports automatically.
  4. 4 Attach a domain if you want HTTPS. Traefik auto-provisions the Let's Encrypt certificate.

What is Directus with PostgreSQL?

Directus is an open-source headless CMS and data platform that wraps any SQL database in a beautiful admin UI plus auto-generated REST and GraphQL APIs. This template ships Directus with a dedicated PostgreSQL backend — the production-recommended database — pre-wired in one Pier stack.

You log into Directus and define collections (which become Postgres tables), add fields (columns), wire relations, set roles and permissions. Everything is reflected in plain SQL, queryable from any PostgreSQL client. The REST/GraphQL endpoints update automatically as your schema evolves.

Use cases — headless backend for a website/app, multi-user editorial CMS, admin UI on top of an existing Postgres application database, or the backend layer of a SaaS MVP.

How Pier deploys it

Pier uses the official directus/directus image plus postgres:17-alpine. Default ports — Directus on 8055 internally (behind Traefik), Postgres on the internal Docker network.

Persistent volumes — Directus uploads at /directus/uploads, extensions at /directus/extensions, plus /var/lib/postgresql/data for Postgres.

First-launch admin user is created via env vars (Pier generates a strong password). Log in at the public URL and start defining collections.

For HTTPS, attach a custom domain in Pier — Traefik handles TLS.

When NOT to use this template

For a one-editor blog or development, the standalone Directus (SQLite) template is simpler. For a non-CMS internal tools platform with workflows and plugins, NocoBase (this catalog) is a better fit. For a “PostgreSQL + auth + storage + edge functions” full-stack backend, look at Supabase. Directus is the right answer for “headless CMS / data platform on SQL with a great admin UI.”

Key features

Production-ready Directus

Full Directus — visual data modeling, REST + GraphQL APIs, RBAC, flows (automations), webhooks, file upload — backed by PostgreSQL for concurrent multi-user workloads.

Pre-wired DB config

Pier sets DB_CLIENT=pg, DB_HOST/DATABASE/USER/PASSWORD env vars. Directus boots straight into Postgres on first launch.

SQL-first data modeling

Directus wraps your existing SQL schema (or one it provisions) in a beautiful UI. The DB stays a normal PostgreSQL DB — query it from anywhere.

REST + GraphQL out of the box

Every collection automatically exposes REST and GraphQL endpoints. Auth via JWT, OAuth2/OIDC, or static tokens.

Flows (automations)

Visual workflow builder for webhook handling, scheduled jobs, data transformations. Like n8n inside your CMS.

Beautiful admin UI

Dashboards, table views, edit forms, file library, version history. Among the best-looking CMS admin UIs available.

Use cases

Multi-user content team

Editors, reviewers, translators on dashboards concurrently — Postgres handles concurrent writes that SQLite can't.

Headless backend for web + mobile

Single Directus instance feeding your Next.js/Astro/Vue site plus iOS/Android apps via REST or GraphQL.

Internal admin on existing Postgres

Point Directus at an existing application Postgres DB — instant admin UI for tables you already have.

Backend for SaaS MVPs

REST/GraphQL/auth/RBAC/file-upload/automations — Directus replaces 80% of a hand-built backend for early-stage SaaS.

i18n CMS

Translation interfaces, locale-aware fields, content versioning for multi-language sites.

Code examples

Define a "posts" collection (UI) text
Data Model → Create Collection → "posts"
Add fields:
  - title (text)
  - body (rich text)
  - status (dropdown: draft/published)
  - cover (file)
  - author (m2o → directus_users)
  - tags (m2m → tags)
Save — REST/GraphQL endpoints auto-generated.
REST API — fetch posts bash
curl https://cms.example.com/items/posts?filter[status][_eq]=published&fields=*.* \
  -H "Authorization: Bearer $TOKEN"
GraphQL query graphql
query {
  posts(filter: { status: { _eq: "published" } }) {
    id
    title
    body
    cover { id filename_download }
    author { first_name last_name }
  }
}
Webhook on item update (Flow) text
Flow trigger: "Action — items.update on posts"
→ Operation: "Send Webhook"
  URL: https://my-site.example.com/revalidate
  Method: POST
  Body: { "slug": "{{ $trigger.payload.slug }}" }

How it compares

vs Directus with SQLite (default standalone) SQLite Directus is fine for one editor or development. Postgres is required for multi-user content teams and any production load.
vs Strapi Strapi is JavaScript-first, plugin-rich, but heavier and SQLite-default. Directus is database-agnostic, wraps your existing schema, and the admin UI is more polished.
vs Supabase (this catalog) Supabase is "PostgreSQL + auth + storage + edge functions for app backends." Directus is "PostgreSQL + admin UI + content workflows for CMS use cases." Different sweet spots; both build on Postgres.
vs Sanity / Contentful SaaS-only, pay-per-use. Directus is self-hosted, free, you own the data and the database.
vs NocoBase NocoBase is no-code-first with plugin extensibility. Directus is admin-UI-on-SQL-first. Pick by primary use — content management (Directus) vs internal tools (NocoBase).

Frequently asked questions

Why PostgreSQL over SQLite?
Multi-user concurrent editing, larger data volumes, HA setups all need Postgres. SQLite is fine for single-editor or dev only.
Can I migrate from SQLite Directus?
Use Directus's CLI to export schema + content, deploy this template, import via CLI. Workflows / users / configurations export cleanly.
Can it wrap an existing Postgres?
Yes — Directus' main feature. Point it at an existing DB with `DB_CLIENT=pg` and connection details; Directus introspects schemas and exposes them as collections immediately.
Auth / SSO?
Yes — Directus supports OpenID Connect, OAuth2, SAML, LDAP, plus static tokens for service accounts.
File uploads — where do they go?
Local disk volume by default. Switch to S3/MinIO/R2/GCS/Azure via env vars for cloud storage.
Performance with many collections?
Directus is built for "thousands of items per collection, dozens of collections" easily. Beyond that, query patterns matter — index your hot foreign keys.
Backup strategy?
pg_dump the Directus DB + back up the uploaded-files volume. Both restore cleanly to a fresh instance.

Related services

Deploy on your VPS

Directus (the open-source headless CMS and data platform) paired with a dedicated PostgreSQL backend in one Pier stack. Pre-wired env vars, persistent volumes, ready for production multi-user content teams or any use case where SQLite is no longer enough.

Deploy this service →