Skip to content

Commit

Permalink
template created
Browse files Browse the repository at this point in the history
  • Loading branch information
davepoon committed Dec 16, 2023
0 parents commit 2afdd28
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
# Always increase the version requirement
# to match the new version.
versioning-strategy: increase
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules
.env
data
database
uploads
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Explicitly specify a Directus version to use on Railway
FROM directus/directus:10.8.2

USER root
RUN corepack enable
USER node

# Installing contributed/custom extensions through npm on Railway
RUN pnpm install directus-extension-computed-interface && pnpm install directus-extension-upsert && pnpm install directus-extension-wpslug-interface && pnpm install pg

# Uncomment this if you would like to install contributed/custom extensions through the extensions folder on Railway
#COPY ./extensions /directus/extensions

COPY ./config.js /directus/config.js

70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Directus (Docker + extensions + websocket) + PostGIS (Docker & TCP) + S3
description: A one-click-install Directus instance with PostGIS and S3 for persistent storage.
tags:
- Directus
- Typescript
- Vue
- Websocket
- CMS
- Data Platform
- PostgreSQL
- PostGIS
- Railway
---

# Directus railway template

This example runs a [Directus](https://directus.io/) instance with minimal config using PostGIS.

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/zAZIod?referralCode=OYCuBb)

## ✨ Features

- Directus config is pre-configured
- Install Directus using Docker
- Directus extensions and websocket are pre-configured
- Directus version can be updated through Dockerfile
- Directus extensions can be updated and loaded through Dockerfile
- PostGIS config is pre-configured
- SSL certificates is pre-configured using the self-signed Snakeoil certificate for PostGIS
- Railway Database View is pre-configured
- Install PostGIS instead of Postgre as Directus recommended for supporting GIS features
- S3 for persistent storage
- docker-compose.yml is added for local development
- The communication from Directus to the database is accomplished through the private network, saving its users from egress fees. This reduces the users' exposure to unnecessary egress fees.

## 💁‍♀️ How to use

- Click the Deploy on Railway button
- Let railway deploy your service, most of the configurations have been preset, but feel free to tweak them as you like before deployment.
- Login in the admin panel using the defined ADMIN_EMAIL and ADMIN_PASSWORD.
- Use of S3 is a must in this template.
- For local development, just run `docker compose up` or run the same command twice (Sometimes, the Directus container starts before other containers are ready, resulting in a failure upon startup).


## 💁‍♀️ Example screenshots

**Directus extensions**

![Directus extensions!](https://zyugzloemocjcxmspsso.supabase.co/storage/v1/object/public/static-assets/extensions.png?t=2023-12-15T10%3A32%3A35.939Z "Directus extensions enabled")

**Directus S3 image upload**

![Directus S3 image upload!](https://zyugzloemocjcxmspsso.supabase.co/storage/v1/object/public/static-assets/s3-file-upload.png "Directus S3 image upload")

**Directus S3 storage**

![Directus S3 storage!](https://zyugzloemocjcxmspsso.supabase.co/storage/v1/object/public/static-assets/s3-storage.png "Directus S3 storage")

**Railway Database View for Postgis**

![Railway Database View for Postgis!](https://zyugzloemocjcxmspsso.supabase.co/storage/v1/object/public/static-assets/database-view.png "Railway Database View for Postgis")

## 📝 Notes

- This is a minimal one-click-deploy solution to Directus, see [Directus docs](https://docs.directus.io/getting-started/introduction.html) to config it to your needs.

## Credit

- Inspired and learnt from [https://github.com/freekrai/directus-railway](https://github.com/freekrai/directus-railway) and [https://railway.app/template/postgis](https://railway.app/template/postgis)
26 changes: 26 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default function (env) {
return {
// Railway inputs
ADMIN_EMAIL: env.ADMIN_EMAIL,
ADMIN_PASSWORD: env.ADMIN_PASSWORD,
KEY: env.KEY,
SECRET: env.SECRET,

// https://docs.railway.app/guides/public-networking#railway-provided-port
PORT: env.PORT,

PUBLIC_URL: `http://0.0.0.0:${env.PORT}`,

// Database & storage variables for connecting to PostGIS and S3/local storage
DB_CLIENT: 'pg',
DB_CONNECTION_STRING: env.DB_CONNECTION_STRING,
STORAGE_LOCATIONS: env.STORAGE_LOCATIONS,
STORAGE_S3_DRIVER: env.STORAGE_S3_DRIVER,
STORAGE_S3_KEY: env.STORAGE_S3_KEY,
STORAGE_S3_SECRET: env.STORAGE_S3_SECRET,
STORAGE_S3_REGION: env.STORAGE_S3_REGION,
STORAGE_S3_BUCKET: env.STORAGE_S3_BUCKET,
STORAGE_S3_ENDPOINT: env.STORAGE_S3_ENDPOINT,
WEBSOCKETS_ENABLED: env.WEBSOCKETS_ENABLED,
};
};
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# For local development, you can use the following docker-compose.yml file:
version: "3"
services:
database:
image: postgis/postgis:13-master
# Required when running on platform other than amd64, like Apple M1/M2:
platform: linux/amd64
volumes:
- ./data/database:/var/lib/postgresql/data
environment:
POSTGRES_USER: "directus"
POSTGRES_PASSWORD: "directus"
POSTGRES_DB: "directus"

cache:
image: redis:6

directus:
image: directus/directus:10.8.2
ports:
- 8055:8055
volumes:
- ./database:/directus/database
- ./uploads:/directus/uploads
- ./extensions:/directus/extensions
depends_on:
- cache
- database
environment:
KEY: "255d861b-5ea1-5996-9aa3-922530ec40b1"
SECRET: "6116487b-cda1-52c2-b5b5-c8022c45e263"

DB_CLIENT: "pg"
DB_HOST: "database"
DB_PORT: "5432"
DB_DATABASE: "directus"
DB_USER: "directus"
DB_PASSWORD: "directus"

CACHE_ENABLED: "true"
CACHE_STORE: "redis"
REDIS: "redis://cache:6379"

ADMIN_EMAIL: "[email protected]"
ADMIN_PASSWORD: "d1r3ctu5"

EXTENSIONS_AUTO_RELOAD: "true"

# Make sure to set this in production
# (see https://docs.directus.io/self-hosted/config-options#general)
# PUBLIC_URL: "https://directus.example.com"
Empty file added extensions/displays/.gitkeep
Empty file.
Empty file added extensions/endpoints/.gitkeep
Empty file.
Empty file added extensions/hooks/.gitkeep
Empty file.
Empty file added extensions/interfaces/.gitkeep
Empty file.
Empty file added extensions/layouts/.gitkeep
Empty file.
Empty file added extensions/modules/.gitkeep
Empty file.
Empty file added extensions/panels/.gitkeep
Empty file.
21 changes: 21 additions & 0 deletions railway.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://schema.up.railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"phases": {
"setup": {
"nixPkgs": [
"...",
"gcc",
"python311"
],
"aptPkgs": [
"build-essential",
"glibc-source"
]
}
}
}
}
}

0 comments on commit 2afdd28

Please sign in to comment.