Quickly Deploy Directus on Railway

Roger Stringer

Roger Stringer / August 18, 2022

2 min read

Quickly Deploy Directus on Railway

Directus is one of the nicer headless CMSes out there, their UX, API, Insights and Flow engine make it a powerful tool.

I set up this repo to quickly get started on Railway, it uses Postgres for the database, S3 for file storage and also includes https://github.com/dimitrov-adrian/directus-extension-wpslug-interface extension already setup to handle generating slugs.

Click here to open the repo and get started.

That’s it, there’s a button to push that will take you to Railway and guide you through setting up your site.

I highly recommend taking a look at the Directus examples repo to get a feel for what you can do using Directus with various frameworks like Next, Remix, Nuxt, Astro, etc.

Further Config

You should also read over the self-hosted docs which can show any further config you can add such as Redis cache, or configuring email to send via a service of your choice, these can all be configured in the railway dashboard pretty quickly.

For example, to tell the app to send email using Sendgrid:

EMAIL_FROM=you@youremail.com
EMAIL_TRANSPORT=smtp
EMAIL_SMTP_HOST=smtp.sendgrid.net
EMAIL_SMTP_PORT=587
EMAIL_SMTP_USER=apikey
EMAIL_SMTP_PASSWORD=YOUR-SENDGRID-API-KEY

Or to enable Redis cache, add a Redis service to your Railway app and add the following env vars:

CACHE_ENABLED=true
CACHE_STORE=redis
CACHE_REDIS=redis://your-redis-connection-string
CACHE_TTL=15m
CACHE_AUTO_PURGE=true

If you want cache but don’t want Redis, you can also just set the app to use a memory cache with:

CACHE_ENABLED=true
CACHE_STORE=memory
CACHE_TTL=15m
CACHE_AUTO_PURGE=true

Or you can leave caching off entirely like it is by default.

Upgrading

I’ll keep the repo up to date as new releases come out which Railway will show in their dashboard and let you push to your own, it’s currently set to grab the latest during builds.

But if you want to upgrade yourself, then you just have to set the directus version in your package.json to the latest version number, currently it’s 9.18.1.

Do you like my content?

Sponsor Me On Github