---
title: Deploy Directus with AI on Blossom
url: "/deploy/directus/"
canonical_url: https://blossom88.com/deploy/directus/
markdown_url: https://blossom88.com/deploy/directus.md
summary: Deploy Directus with AI on Blossom. Build a content API with a visual editor,
  managed PostgreSQL and Redis, and private R2 file storage.
categories:
- deployment
- cms
- backend
stack:
- TypeScript
- Node.js
- Vue
- PostgreSQL
- Redis
---

# Deploy Directus with AI on Blossom

[Directus](https://directus.com/) turns a SQL database into a content API and
a visual editor for your team. Use it as a headless CMS or an application
backend, with permissions controlling who can read and change each record.

## Ask Your Agent

> **Ask your AI agent:** Deploy Directus on Blossom and help me build an API for my content.
>
> Follow this guide: https://blossom88.com/deploy/directus/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## Your Content Setup

| Part | Purpose |
|---|---|
| Directus | Visual editor, content APIs, permissions and file access |
| Managed PostgreSQL | Content, users, permissions and file metadata |
| Managed Redis | Coordinates Directus Containers and shared caches |
| Your private R2 bucket | Stores uploaded files independently of Containers |

Bring a private R2 bucket; Directus serves files through its permissioned
asset API. Check the [license requirements](https://directus.com/docs/licensing/overview)
for your team and features. Custom permission rules for draft and published
records require a suitable license.

![Directus Studio editing an article with an R2 cover image](/deploy/assets/images/directus/editor.png)

<details class="optional-reading" markdown="1">
<summary>Deployment setup and commands</summary>

Create a private R2 bucket in **your own Cloudflare account**. Directus serves
uploads through its authenticated asset API, so the bucket doesn't need a
public domain. Give it a bucket-restricted credential and keep the values in
a private environment file. Give your agent that file's path, not the
credentials in chat.

Check the current [Directus licensing requirements](https://directus.com/docs/licensing/overview)
for your team and features. The free Core tier works without a license key;
higher limits and features have their own requirements. Custom permission
rules, including row filters for draft versus published records, need a
suitable license.

Upstream requirements: [Directus requirements](https://directus.com/docs/self-hosting/requirements).

Directus uses regular App Capacity without an attached Volume. Keep its
`SECRET` stable across Containers and updates. Set the first administrator's
email and strong password privately; sign in to Studio at your App's HTTPS
address.

Run Directus's supported bootstrap command once in Blossom's **Release Phase**
to initialize or migrate the database. Start web Containers without repeating
that bootstrap in each one. The hook inherits the application's Container
resources.

Your agent prepares each file with your Location, selected image and resources.
Pin the image's multi-architecture index when available.

    blossom profile:show
    blossom app:create --data app.yml
    blossom environment:create --data environment.yml
    blossom database_instance:create --data database_instance.yml --follow
    blossom cache_instance:create --data cache_instance.yml --follow
    blossom database:list --database_instance database_instance-100
    blossom environment_link:create --data database-link.yml
    blossom environment_link:create --data redis-link.yml

Link the Database as `DATABASE_URL` and Redis as `REDIS_URL`. Map these to
Directus's `DB_CONNECTION_STRING` and `REDIS` settings in both the Release
Phase and web startup commands. Set `DB_CLIENT=pg`.

Configure the selected release's [S3 storage driver](https://directus.com/docs/configuration/files):
`STORAGE_LOCATIONS=r2`, `STORAGE_R2_DRIVER=s3`, `STORAGE_R2_BUCKET`,
`STORAGE_R2_ENDPOINT`, `STORAGE_R2_REGION=auto` and, when sharing a bucket,
`STORAGE_R2_ROOT` for this App's prefix. Set the driver's key and secret using
the bucket credential.

For temporary session credentials, leave `STORAGE_R2_KEY` and
`STORAGE_R2_SECRET` unset and use `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
and `AWS_SESSION_TOKEN` through the SDK's default credential chain. Retained
Apps need a suitable credential lifetime or automatic renewal.

Use the current release's [Redis synchronization settings](https://directus.com/docs/configuration/synchronization).
Set `SYNCHRONIZATION_STORE=redis`; shared caching also uses
`CACHE_STORE=redis`. When enabling the response cache, configure invalidation
with `CACHE_AUTO_PURGE=true`.

    blossom env_var:push --environment environment-100 --file .env.production
    blossom service:create --data service.yml
    blossom environment:deploy_hooks:update --id environment-100 --data deploy_hooks.yml
    blossom environment:deploy --id environment-100 --follow
    blossom environment:show --id environment-100

For the tested official image, Release Phase runs `node cli.js bootstrap` and
web startup runs `node cli.js start`, after mapping the linked variables.
Check these commands against the selected image. Set `PUBLIC_URL` to the
App's public HTTPS origin and configure an HTTP health check on
`/server/ping`.

</details>

## Create Your First Collection

Create an articles collection in Studio and give your website a read policy.
Keep write credentials on your backend. With the Core tier, keep editorial
drafts in a separate, unshared collection. PostgreSQL and R2 keep content and
uploads across Container replacement.

<details class="optional-reading" markdown="1">
<summary>Updates and scaling</summary>

Keep the same PostgreSQL, Redis, bucket, `SECRET` and public URL across
Containers. Redis coordinates synchronization; storing files in R2 removes
the local upload Volume's single-Container constraint. Content, login,
permissions and uploaded files survived replacing both Containers on
Blossom.

Package [extensions](https://directus.com/docs/self-hosting/including-extensions)
in the deployment image so every Container starts with the same code.
Marketplace installations saved only to a Container's local filesystem do
not survive replacement.

### Scaling commands

    blossom service:scale --id service-100 --desired-size 2 --follow
    blossom container:list --service service-100


</details>

## What You Get

- Your own Directus editor and content API
- Managed data and private R2 uploads
- A shared configuration ready for more Containers
