重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
npx skills add https://github.com/hoodini/ai-agents-skills --skill railway在 Railway 平台上部署和管理应用程序。
# 安装 Railway CLI
npm i -g @railway/cli
# 登录
railway login
# 初始化项目
railway init
# 部署
railway up
[build]
builder = "nixpacks"
buildCommand = "npm run build"
[deploy]
startCommand = "npm start"
healthcheckPath = "/health"
healthcheckTimeout = 300
restartPolicyType = "on_failure"
restartPolicyMaxRetries = 3
[service]
internalPort = 3000
# nixpacks.toml
[phases.setup]
nixPkgs = ["nodejs-18_x", "python311"]
[phases.install]
cmds = ["npm ci"]
[phases.build]
cmds = ["npm run build"]
[start]
cmd = "npm start"
# 设置变量
railway variables set DATABASE_URL="postgres://..."
# 从文件设置
railway variables set < .env
# 链接到服务
railway service
railway variables set API_KEY="secret"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 添加 PostgreSQL
railway add -d postgres
# 获取连接字符串
railway variables get DATABASE_URL
railway add -d redis
# 通过 REDIS_URL 访问
railway add -d mysql
# 通过 MYSQL_URL 访问
# 服务可以通过内部 DNS 通信
# 格式:${{service-name}}.railway.internal
# 示例:API 调用数据库服务
DATABASE_HOST: ${{postgres.railway.internal}}
DATABASE_PORT: 5432
# 创建卷
railway volume create my-data
# 挂载到服务中
railway volume attach my-data:/app/data
在代码中:
// 数据在多次部署间持久保存
const dataPath = '/app/data';
fs.writeFileSync(`${dataPath}/file.json`, JSON.stringify(data));
# railway.toml
[deploy]
startCommand = "node cron.js"
cronSchedule = "0 */6 * * *" # 每 6 小时
my-project/
├── api/
│ ├── railway.toml
│ └── ...
├── worker/
│ ├── railway.toml
│ └── ...
└── frontend/
├── railway.toml
└── ...
分别部署:
cd api && railway up
cd ../worker && railway up
cd ../frontend && railway up
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
# railway.toml
[build]
builder = "dockerfile"
dockerfilePath = "./Dockerfile"
// Express 健康检查端点
app.get('/health', (req, res) => {
res.status(200).json({
status: 'healthy',
timestamp: new Date().toISOString()
});
});
# railway.toml
[deploy]
healthcheckPath = "/health"
healthcheckTimeout = 100
每周安装量
50
仓库
GitHub 星标数
140
首次出现
Jan 24, 2026
安全审计
安装于
gemini-cli41
opencode41
codex40
github-copilot39
cursor38
claude-code37
Deploy and manage applications on Railway's platform.
# Install Railway CLI
npm i -g @railway/cli
# Login
railway login
# Initialize project
railway init
# Deploy
railway up
[build]
builder = "nixpacks"
buildCommand = "npm run build"
[deploy]
startCommand = "npm start"
healthcheckPath = "/health"
healthcheckTimeout = 300
restartPolicyType = "on_failure"
restartPolicyMaxRetries = 3
[service]
internalPort = 3000
# nixpacks.toml
[phases.setup]
nixPkgs = ["nodejs-18_x", "python311"]
[phases.install]
cmds = ["npm ci"]
[phases.build]
cmds = ["npm run build"]
[start]
cmd = "npm start"
# Set variable
railway variables set DATABASE_URL="postgres://..."
# Set from file
railway variables set < .env
# Link to service
railway service
railway variables set API_KEY="secret"
# Add PostgreSQL
railway add -d postgres
# Get connection string
railway variables get DATABASE_URL
railway add -d redis
# Access via REDIS_URL
railway add -d mysql
# Access via MYSQL_URL
# Services can communicate via internal DNS
# Format: ${{service-name}}.railway.internal
# Example: API calling database service
DATABASE_HOST: ${{postgres.railway.internal}}
DATABASE_PORT: 5432
# Create volume
railway volume create my-data
# Mount in service
railway volume attach my-data:/app/data
In code:
// Data persists across deploys
const dataPath = '/app/data';
fs.writeFileSync(`${dataPath}/file.json`, JSON.stringify(data));
# railway.toml
[deploy]
startCommand = "node cron.js"
cronSchedule = "0 */6 * * *" # Every 6 hours
my-project/
├── api/
│ ├── railway.toml
│ └── ...
├── worker/
│ ├── railway.toml
│ └── ...
└── frontend/
├── railway.toml
└── ...
Deploy each:
cd api && railway up
cd ../worker && railway up
cd ../frontend && railway up
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
# railway.toml
[build]
builder = "dockerfile"
dockerfilePath = "./Dockerfile"
// Express health endpoint
app.get('/health', (req, res) => {
res.status(200).json({
status: 'healthy',
timestamp: new Date().toISOString()
});
});
# railway.toml
[deploy]
healthcheckPath = "/health"
healthcheckTimeout = 100
Weekly Installs
50
Repository
GitHub Stars
140
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykFail
Installed on
gemini-cli41
opencode41
codex40
github-copilot39
cursor38
claude-code37
Azure 配额管理指南:服务限制、容量验证与配额增加方法
138,600 周安装