AgentSkillsCN

Railway Templates

Railway模板

SKILL.md

Railway Templates

Deploy from Railway's 650+ template library

Activation Triggers

  • Deploying databases (Postgres, MySQL, Redis, MongoDB)
  • Adding message queues (RabbitMQ, Redis)
  • Deploying pre-built services
  • Using deploy-template tool

Using deploy-template

The deploy-template tool deploys services from Railway's template marketplace.

Syntax

code
deploy-template with description of what you need

Examples

code
"Deploy a Postgres database"
"Deploy Redis for caching"
"Deploy a MongoDB database"
"Deploy RabbitMQ for message queuing"

Popular Database Templates

PostgreSQL

code
deploy-template: "Postgres database"

Variables provided:

  • DATABASE_URL - Full connection string
  • PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE

Use in your app:

code
DATABASE_URL=${{Postgres.DATABASE_URL}}

MySQL

code
deploy-template: "MySQL database"

Variables provided:

  • MYSQL_URL - Full connection string
  • MYSQLHOST, MYSQLPORT, MYSQLUSER, MYSQLPASSWORD, MYSQLDATABASE

Use in your app:

code
DATABASE_URL=${{MySQL.MYSQL_URL}}

MongoDB

code
deploy-template: "MongoDB database"

Variables provided:

  • MONGO_URL - Full connection string

Use in your app:

code
MONGODB_URI=${{MongoDB.MONGO_URL}}

Cache & Queue Templates

Redis

code
deploy-template: "Redis"

Variables provided:

  • REDIS_URL - Full connection string

Use in your app:

code
REDIS_URL=${{Redis.REDIS_URL}}

Common uses:

  • Session storage
  • Caching
  • Rate limiting
  • Pub/sub messaging
  • Job queues (with Bull/BullMQ)

RabbitMQ

code
deploy-template: "RabbitMQ"

Variables provided:

  • RABBITMQ_URL - AMQP connection string

Use in your app:

code
RABBITMQ_URL=${{RabbitMQ.RABBITMQ_URL}}

Search & Analytics Templates

Meilisearch

code
deploy-template: "Meilisearch"

Full-text search engine.

Typesense

code
deploy-template: "Typesense"

Typo-tolerant search engine.

ClickHouse

code
deploy-template: "ClickHouse"

Analytics database for OLAP workloads.


Storage Templates

MinIO

code
deploy-template: "MinIO"

S3-compatible object storage.

Variables provided:

  • MINIO_ROOT_USER
  • MINIO_ROOT_PASSWORD
  • Endpoint URL

Application Templates

n8n

code
deploy-template: "n8n"

Workflow automation platform.

Metabase

code
deploy-template: "Metabase"

Business intelligence and analytics.

Strapi

code
deploy-template: "Strapi"

Headless CMS.

Ghost

code
deploy-template: "Ghost"

Publishing platform.

Uptime Kuma

code
deploy-template: "Uptime Kuma"

Self-hosted monitoring tool.


Template Deployment Workflow

Basic: Add Database to Existing Project

code
1. check-railway-status
2. deploy-template "Postgres database"
3. list-variables (on Postgres service)
4. set-variables (on your app):
   DATABASE_URL=${{Postgres.DATABASE_URL}}
5. deploy

Full Stack: App + Database

code
1. check-railway-status
2. create-project-and-link
3. deploy-template "Postgres database"
4. set-variables:
   NODE_ENV=production
   DATABASE_URL=${{Postgres.DATABASE_URL}}
5. deploy
6. generate-domain

App + Database + Cache

code
1. check-railway-status
2. create-project-and-link
3. deploy-template "Postgres database"
4. deploy-template "Redis"
5. set-variables:
   DATABASE_URL=${{Postgres.DATABASE_URL}}
   REDIS_URL=${{Redis.REDIS_URL}}
6. deploy
7. generate-domain

Template Selection Guide

NeedTemplate
Relational dataPostgreSQL, MySQL
Document storageMongoDB
CachingRedis
SessionsRedis
Job queuesRedis + Bull, RabbitMQ
Full-text searchMeilisearch, Typesense
File storageMinIO
Analytics DBClickHouse
MonitoringUptime Kuma
CMSStrapi, Ghost

Connecting Templates to Your App

Pattern 1: Reference Variable

code
# In your app's environment variables:
DATABASE_URL=${{Postgres.DATABASE_URL}}

Pattern 2: Private Networking

code
# For internal-only access:
DB_HOST=${{Postgres.RAILWAY_PRIVATE_DOMAIN}}
DB_PORT=5432

Pattern 3: Multiple Databases

code
# Primary database
DATABASE_URL=${{Postgres.DATABASE_URL}}

# Read replica (if set up)
DATABASE_REPLICA_URL=${{Postgres-Replica.DATABASE_URL}}

# Cache
REDIS_URL=${{Redis.REDIS_URL}}

Template Customization

After deploying a template, you can customize it:

Changing Database Settings

code
1. list-services → Find database service
2. set-variables (on database service):
   POSTGRES_MAX_CONNECTIONS=200
3. Service restarts with new config

Persistent Storage

Most database templates include persistent volumes by default. Data survives restarts.


Common Template Configurations

Postgres with Extensions

Some Postgres templates support extensions:

code
# Enable in your migration or connection
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";

Redis Persistence

Railway's Redis template typically has persistence enabled:

  • AOF (Append Only File) for durability
  • RDB snapshots

MongoDB Replica Set

For production, consider MongoDB Atlas integration or multiple MongoDB instances.


Troubleshooting Templates

Template not connecting

code
1. list-services → Verify template deployed
2. list-variables → Check connection variables exist
3. Verify reference syntax: ${{ServiceName.VARIABLE}}

Template using too many resources

code
1. Check Railway dashboard for metrics
2. Consider upgrading plan for more resources
3. Optimize queries/usage patterns

Template data disappeared

code
1. Check if volume is attached
2. Verify service wasn't deleted
3. Check deployment logs

Browse All Templates

Visit railway.com/templates for:

  • 650+ templates
  • One-click deployments
  • Community contributions
  • Official Railway templates

Quick Reference

I want...Template
SQL databasePostgres or MySQL
NoSQL databaseMongoDB
CacheRedis
Message queueRabbitMQ or Redis
SearchMeilisearch
Object storageMinIO
MonitoringUptime Kuma