jpskill.com
🛠️ 開発・MCP コミュニティ

railway-deployment

GitHub、Docker、ローカル環境からRailway.comへのデプロイ、再デプロイ、ロールバック、状況監視、ステージング/本番環境管理、デプロイの健全性確認など、Railway.comのデプロイを総合的に管理するSkill。

📜 元の英語説明(参考)

Comprehensive Railway.com deployment management for GitHub, Docker, and local sources. Use when deploying to Railway, redeploying services, rolling back deployments, monitoring deployment status, managing staging/production deployments, or verifying deployment health.

🇯🇵 日本人クリエイター向け解説

一言でいうと

GitHub、Docker、ローカル環境からRailway.comへのデプロイ、再デプロイ、ロールバック、状況監視、ステージング/本番環境管理、デプロイの健全性確認など、Railway.comのデプロイを総合的に管理するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o railway-deployment.zip https://jpskill.com/download/9473.zip && unzip -o railway-deployment.zip && rm railway-deployment.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/9473.zip -OutFile "$d\railway-deployment.zip"; Expand-Archive "$d\railway-deployment.zip" -DestinationPath $d -Force; ri "$d\railway-deployment.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して railway-deployment.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → railway-deployment フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Railway デプロイメント管理

Railway.com の完全なデプロイメントワークフロー。複数のソースからのデプロイメント、ロールバック戦略、ヘルス検証、ステージングから本番環境へのプロモーションを含みます。

概要

このスキルは、Railway の包括的なデプロイメント管理を提供します。

  • ソースからのデプロイ: GitHub の自動デプロイ、Docker イメージ、ローカルディレクトリ
  • デプロイメントの監視: リアルタイムログ、ステータス追跡、ビルドの進捗
  • ヘルス検証: 自動化されたヘルスチェックと検証
  • ロールバック戦略: 以前のデプロイメントへの安全なロールバック
  • 環境管理: ステージング → 本番環境のワークフロー
  • CI/CD 統合: 自動化されたデプロイメントパイプライン

前提条件

  • Railway CLI がインストールされ、認証されていること (railway-auth スキルを使用)
  • プロジェクトがリンクされていること (railway-project-management スキルを使用)
  • ターゲット環境にサービスが作成されていること

使用する場面

  • 新しいコードを Railway にデプロイする場合
  • 構成変更後に再デプロイする場合
  • 失敗したデプロイメントをロールバックする場合
  • ステージング環境を本番環境に昇格させる場合
  • 自動デプロイメントを設定する場合
  • デプロイメントの進捗を監視する場合
  • デプロイメントのヘルス状態を確認する場合

5 ステップのデプロイメントワークフロー

ステップ 1: デプロイメントの準備

デプロイする前に、認証、プロジェクトコンテキスト、およびサービスのヘルス状態を確認します。

コマンド:

# 認証の確認
railway whoami

# プロジェクトと環境のコンテキストの確認
railway status

# 現在の環境のサービス一覧
railway list

# 現在のデプロイメントステータスの確認
railway status --json

デプロイ前のチェックリスト:

  • [ ] Railway で認証されている
  • [ ] 正しいプロジェクトがリンクされている
  • [ ] ターゲット環境が選択されている
  • [ ] サービスが環境に存在している
  • [ ] 保留中のデプロイメントがない
  • [ ] 環境変数が設定されている

自動化の使用:

.claude/skills/railway-deployment/scripts/pre-deploy-check.sh

ステップ 2: デプロイ

GitHub、Docker、またはローカルディレクトリからデプロイします。

GitHub からのデプロイ (自動デプロイ)

自動デプロイの設定:

# サービスを GitHub リポジトリにリンク
railway add --repo owner/repository

# ブランチの設定 (ダッシュボードまたは railway.json 経由)
railway open

デプロイメントのトリガー:

# 設定されたブランチにプッシュ
git push origin main

# Railway が自動的にデプロイ
# リアルタイムで監視:
railway logs --deployment

手動再デプロイ:

# 最新のコミットを再デプロイ
railway redeploy

# 特定のデプロイメント ID を再デプロイ
railway redeploy --deployment <deployment-id>

ローカルディレクトリからのデプロイ

現在のディレクトリをデプロイ:

# デプロイして完了を待つ
railway up

# 待たずにデプロイ (デタッチ)
railway up --detach

# CI モードでデプロイ (ビルドログのみ)
railway up --ci

# 特定のサービスをデプロイ
railway up --service backend

何が起こるか:

  1. CLI がローカルディレクトリを Railway にアップロード
  2. Railway がビルド構成を検出 (Nixpacks/Dockerfile)
  3. ビルドが自動的に開始
  4. ビルドが成功するとデプロイメントがトリガー
  5. サービスが新しいコードで再起動

Docker イメージからのデプロイ

パブリックイメージ:

# Docker Hub イメージをデプロイ
railway add --image postgres:15

# タグ付きでデプロイ
railway add --image myapp/backend:v1.2.3

プライベートレジストリ:

# レジストリの認証情報を設定
railway variables set --sealed DOCKER_USERNAME=user
railway variables set --sealed DOCKER_PASSWORD=pass

# プライベートレジストリからデプロイ
railway add --image registry.example.com/app:latest

イメージタグの更新 (ロールバック/アップグレード):

# 環境変数経由
railway variables set IMAGE_TAG=v1.2.2

# 新しいタグで強制的に再デプロイ
railway redeploy

詳細な構成については、references/deployment-sources.md を参照してください。


ステップ 3: デプロイメントの監視

デプロイメントの進捗を追跡し、問題をリアルタイムで特定します。

リアルタイムログ:

# デプロイメントログを追跡
railway logs --deployment

# サービスでフィルタリング
railway logs --service backend --deployment

# 最後の 100 行を表示
railway logs --tail 100

# タイムスタンプを含める
railway logs --timestamps

デプロイメントステータス:

# デプロイメントステータスを確認
railway status

# 詳細な JSON ステータスを取得
railway status --json | jq '.deployments[0]'

# 最近のデプロイメントを一覧表示
railway list deployments

# 特定のデプロイメントを確認
railway deployment <deployment-id>

ビルドの進捗インジケーター:

Building... ████████░░░░░░░░ 60%
Installing dependencies...
Running build script...
Optimizing assets...

問題の監視:

  • ビルドの失敗 (依存関係の欠落)
  • 環境変数のエラー
  • ポートバインディングの問題
  • メモリ/CPU 制限の超過
  • ヘルスチェックの失敗

自動監視:

# 失敗時に監視してアラート
.claude/skills/railway-deployment/scripts/monitor_deployment.sh

ステップ 4: デプロイメントの検証

デプロイメントが正常で、正しく機能していることを検証します。

ヘルスチェックコマンド:

# サービスのヘルスエンドポイントを確認
curl https://your-service.railway.app/health

# カスタム検証で確認
.claude/skills/railway-deployment/scripts/verify-health.sh

検証チェックリスト:

  • [ ] サービスが実行中である (クラッシュしていない)
  • [ ] ヘルスエンドポイントが 200 OK を返す
  • [ ] 環境変数が正しくロードされている
  • [ ] データベース接続が確立されている
  • [ ] API エンドポイントが応答している
  • [ ] 静的アセットがロードされている
  • [ ] エラーログが存在しない

自動検証:

# 完全なヘルスチェックスイートを実行
.claude/skills/railway-deployment/scripts/deploy.sh --verify

# 出力:
# ✅ Service running
# ✅ Health check passed (200 OK)
# ✅ Environment variables loaded
# ✅ Database connection successful
# ✅ API responding correctly

一般的な検証の問題:

問題 症状 解決策
サービスが起動しない ステータス: "crashed" 起動エラーのログを確認
ヘルスチェックが失敗する 503 Service Unavailable ヘルスエンドポイントのパスを確認
変数が欠落している アプリケーションエラー railway variables list を確認
ポートバインディングエラー "EADDRINUSE" PORT 変数が使用されていることを確認
データベース接続 "ECONNREFUSED" DATABASE_URL が設定されていることを確認

(原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Railway Deployment Management

Complete deployment workflows for Railway.com including deployment from multiple sources, rollback strategies, health verification, and staging-to-production promotion.

Overview

This skill provides comprehensive deployment management for Railway:

  • Deploy from sources: GitHub auto-deploy, Docker images, local directory
  • Monitor deployments: Real-time logs, status tracking, build progress
  • Verify health: Automated health checks and validation
  • Rollback strategies: Safe rollback to previous deployments
  • Environment management: Staging → production workflows
  • CI/CD integration: Automated deployment pipelines

Prerequisites

  • Railway CLI installed and authenticated (use railway-auth skill)
  • Project linked (use railway-project-management skill)
  • Service created in target environment

When to Use

  • Deploying new code to Railway
  • Redeploying after configuration changes
  • Rolling back failed deployments
  • Promoting staging to production
  • Setting up automated deployments
  • Monitoring deployment progress
  • Verifying deployment health

5-Step Deployment Workflow

Step 1: Prepare Deployment

Verify authentication, project context, and service health before deploying.

Commands:

# Verify authentication
railway whoami

# Check project and environment context
railway status

# List services in current environment
railway list

# Check current deployment status
railway status --json

Pre-deployment checklist:

  • [ ] Authenticated with Railway
  • [ ] Correct project linked
  • [ ] Target environment selected
  • [ ] Service exists in environment
  • [ ] No pending deployments
  • [ ] Environment variables set

Use automation:

.claude/skills/railway-deployment/scripts/pre-deploy-check.sh

Step 2: Deploy

Deploy from GitHub, Docker, or local directory.

Deploy from GitHub (Auto-Deploy)

Setup auto-deploy:

# Link service to GitHub repo
railway add --repo owner/repository

# Configure branch (via dashboard or railway.json)
railway open

Trigger deployment:

# Push to configured branch
git push origin main

# Railway automatically deploys
# Monitor in real-time:
railway logs --deployment

Manual redeploy:

# Redeploy latest commit
railway redeploy

# Redeploy specific deployment ID
railway redeploy --deployment <deployment-id>

Deploy from Local Directory

Deploy current directory:

# Deploy and wait for completion
railway up

# Deploy without waiting (detached)
railway up --detach

# Deploy in CI mode (build logs only)
railway up --ci

# Deploy specific service
railway up --service backend

What happens:

  1. CLI uploads local directory to Railway
  2. Railway detects build configuration (Nixpacks/Dockerfile)
  3. Build starts automatically
  4. Deployment triggers on successful build
  5. Service restarts with new code

Deploy from Docker Image

Public image:

# Deploy Docker Hub image
railway add --image postgres:15

# Deploy with tag
railway add --image myapp/backend:v1.2.3

Private registry:

# Set registry credentials
railway variables set --sealed DOCKER_USERNAME=user
railway variables set --sealed DOCKER_PASSWORD=pass

# Deploy from private registry
railway add --image registry.example.com/app:latest

Update image tag (rollback/upgrade):

# Via environment variable
railway variables set IMAGE_TAG=v1.2.2

# Force redeploy with new tag
railway redeploy

See references/deployment-sources.md for detailed configuration.


Step 3: Monitor Deployment

Track deployment progress and identify issues in real-time.

Real-time logs:

# Follow deployment logs
railway logs --deployment

# Filter by service
railway logs --service backend --deployment

# Show last 100 lines
railway logs --tail 100

# Include timestamps
railway logs --timestamps

Deployment status:

# Check deployment status
railway status

# Get detailed JSON status
railway status --json | jq '.deployments[0]'

# List recent deployments
railway list deployments

# Check specific deployment
railway deployment <deployment-id>

Build progress indicators:

Building... ████████░░░░░░░░ 60%
Installing dependencies...
Running build script...
Optimizing assets...

Watch for issues:

  • Build failures (missing dependencies)
  • Environment variable errors
  • Port binding issues
  • Memory/CPU limits exceeded
  • Health check failures

Automated monitoring:

# Monitor and alert on failures
.claude/skills/railway-deployment/scripts/monitor-deployment.sh

Step 4: Verify Deployment

Validate that deployment is healthy and functioning correctly.

Health check commands:

# Check service health endpoint
curl https://your-service.railway.app/health

# Verify with custom validation
.claude/skills/railway-deployment/scripts/verify-health.sh

Validation checklist:

  • [ ] Service is running (not crashed)
  • [ ] Health endpoint returns 200 OK
  • [ ] Environment variables loaded correctly
  • [ ] Database connections established
  • [ ] API endpoints responding
  • [ ] Static assets loading
  • [ ] No error logs present

Automated validation:

# Run full health check suite
.claude/skills/railway-deployment/scripts/deploy.sh --verify

# Output:
# ✅ Service running
# ✅ Health check passed (200 OK)
# ✅ Environment variables loaded
# ✅ Database connection successful
# ✅ API responding correctly

Common validation issues:

Issue Symptom Solution
Service not starting Status: "crashed" Check logs for startup errors
Health check failing 503 Service Unavailable Verify health endpoint path
Variables missing Application errors Check railway variables list
Port binding error "EADDRINUSE" Ensure PORT variable used
Database connection "ECONNREFUSED" Verify DATABASE_URL set

Step 5: Rollback if Needed

Safely rollback to previous deployment if issues are detected.

Quick rollback:

# Redeploy previous deployment
railway redeploy --deployment <previous-deployment-id>

# List recent deployments to find ID
railway list deployments

Automated rollback:

# Rollback with safety checks
.claude/skills/railway-deployment/scripts/rollback.sh

# Rollback to specific version
.claude/skills/railway-deployment/scripts/rollback.sh v1.2.3

Rollback strategies:

  1. Redeploy Previous Commit (GitHub):

    # Find previous working commit
    git log --oneline
    
    # Revert to previous commit
    git revert HEAD
    git push origin main
    
    # Railway auto-deploys
  2. Redeploy Previous Deployment (any source):

    # List deployments
    railway list deployments
    
    # Redeploy specific deployment ID
    railway redeploy --deployment dep_abc123xyz
  3. Docker Image Tag Rollback:

    # Update image tag to previous version
    railway variables set IMAGE_TAG=v1.2.2
    
    # Redeploy with previous tag
    railway redeploy
  4. Environment Variable Rollback:

    # Restore previous variable values
    railway variables set API_VERSION=v1
    railway variables set FEATURE_FLAGS=old-config
    
    # Redeploy with previous config
    railway redeploy

See references/rollback-strategies.md for detailed rollback procedures.

Rollback verification:

# After rollback, verify health
.claude/skills/railway-deployment/scripts/verify-health.sh

# Check logs for errors
railway logs --tail 50

# Verify specific functionality
curl https://your-service.railway.app/api/test

Staging → Production Workflow

Typical promotion flow:

# 1. Deploy to staging first
railway environment staging
railway up

# 2. Verify staging deployment
.claude/skills/railway-deployment/scripts/verify-health.sh

# 3. Run staging tests
npm run test:staging

# 4. Promote to production
railway environment production

# 5. Deploy same code
railway up

# 6. Verify production
.claude/skills/railway-deployment/scripts/verify-health.sh

# 7. Monitor production logs
railway logs --deployment

Automated staging workflow:

# Complete staging → production workflow
.claude/skills/railway-deployment/scripts/promote-to-production.sh

See references/staging-workflow.md for detailed staging strategies.


CI/CD Integration

GitHub Actions

name: Deploy to Railway
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Railway CLI
        run: npm install -g @railway/cli

      - name: Deploy to Railway
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
        run: |
          railway up --ci

      - name: Verify Deployment
        run: |
          sleep 30
          curl -f https://your-service.railway.app/health || exit 1

GitLab CI

deploy:staging:
  stage: deploy
  image: node:20
  script:
    - npm install -g @railway/cli
    - railway environment staging
    - railway up --ci
  environment:
    name: staging
  only:
    - develop

deploy:production:
  stage: deploy
  image: node:20
  script:
    - npm install -g @railway/cli
    - railway environment production
    - railway up --ci
  environment:
    name: production
  only:
    - main
  when: manual

Advanced Deployment Patterns

Blue-Green Deployment

# 1. Deploy to "green" environment
railway environment green
railway up

# 2. Verify green is healthy
.claude/skills/railway-deployment/scripts/verify-health.sh

# 3. Switch traffic to green
# (Update DNS or load balancer)

# 4. Keep blue as rollback option
railway environment blue
# (Don't delete until green is stable)

Canary Deployment

# 1. Deploy canary version
railway environment canary
railway up

# 2. Route small % of traffic to canary
# (Configure via load balancer)

# 3. Monitor canary metrics
railway logs --service canary

# 4. Gradually increase traffic
# (Adjust load balancer weights)

# 5. Promote to production if successful
railway environment production
railway up

Rolling Deployment

# Deploy to instances one at a time
# (Requires horizontal scaling)

# Railway handles rolling deploys automatically
# when multiple replicas are configured
railway up

# Monitors health and rolls back on failure

Deployment Troubleshooting

Build Failures

# Check build logs
railway logs --deployment

# Common issues:
# - Missing package.json
# - Node/Python version mismatch
# - Build command failures
# - Environment variables not set

# Fix and redeploy
railway up

Deployment Stuck

# Check deployment status
railway status --json

# Cancel stuck deployment
railway deployment cancel <deployment-id>

# Redeploy
railway up

Health Check Failures

# Check service logs
railway logs

# Verify health endpoint exists
curl -v https://your-service.railway.app/health

# Check port configuration
railway variables list | grep PORT

# Verify restart policy
railway open  # Check service settings

Memory/CPU Limits

# Check resource usage
railway metrics

# Increase limits (via dashboard)
railway open

# Or upgrade plan

Quick Reference

Core Deployment Commands

Command Description
railway up Deploy local directory
railway up --detach Deploy without waiting
railway up --ci Deploy in CI mode
railway redeploy Redeploy latest deployment
railway logs --deployment Monitor deployment logs
railway status Check deployment status

Deployment Sources

Source Command Auto-Deploy
GitHub railway add --repo owner/repo ✅ Yes (on push)
Local railway up ❌ Manual
Docker railway add --image image:tag ❌ Manual

Environment Workflow

# Staging
railway environment staging
railway up

# Production
railway environment production
railway up

Automated Scripts

Smart Deployment with Health Checks

# Deploy with automatic health verification
.claude/skills/railway-deployment/scripts/deploy.sh

# Deploy specific service
.claude/skills/railway-deployment/scripts/deploy.sh backend

# Deploy with custom health endpoint
.claude/skills/railway-deployment/scripts/deploy.sh backend /api/health

Safe Rollback

# Rollback with confirmation prompt
.claude/skills/railway-deployment/scripts/rollback.sh

# Rollback to specific deployment
.claude/skills/railway-deployment/scripts/rollback.sh dep_abc123

# Emergency rollback (no confirmation)
.claude/skills/railway-deployment/scripts/rollback.sh --force

Pre-Deployment Validation

# Check all prerequisites
.claude/skills/railway-deployment/scripts/pre-deploy-check.sh

# Validates:
# - Railway authentication
# - Project linked
# - Environment selected
# - No pending deployments
# - Variables configured

Related Skills

  • railway-auth: Authenticate with Railway CLI and manage tokens
  • railway-project-management: Create projects, manage environments, configure variables
  • railway-observability: Monitor metrics, logs, and traces
  • railway-api: GraphQL API automation for advanced workflows

Additional Resources

  • References:

    • references/deployment-sources.md: GitHub, Docker, and local deployment details
    • references/rollback-strategies.md: Comprehensive rollback procedures
    • references/staging-workflow.md: Staging → production best practices
  • Scripts:

    • scripts/deploy.sh: Smart deployment with health checks
    • scripts/rollback.sh: Safe rollback with confirmation
    • scripts/verify-health.sh: Automated health validation
    • scripts/pre-deploy-check.sh: Pre-deployment validation
    • scripts/promote-to-production.sh: Staging → production automation
  • Railway Documentation:


Last Updated: November 2025 Status: Production-ready Version: 1.0.0