{
  "manifest_version": "1.0.0",
  "template": {
    "id": "6478776d-829b-4db6-9515-822e6475c2a5",
    "slug": "sub2api-railway",
    "name": "Sub2API Railway",
    "description": "Self-host Sub2API on Railway with PostgreSQL, Redis, and a data volume.",
    "url": "https://railway.com/deploy/sub2api-railway",
    "upstream": {
      "repo_url": "https://github.com/wsbjj/sub2api_railway"
    }
  },
  "status": "unvalidated",
  "validated_at": null,
  "success_rate_30d": null,
  "services": [
    {
      "name": "Sub2API",
      "source": {
        "repo": "https://github.com/wsbjj/sub2api_railway"
      },
      "needs_volume": true,
      "volume_mount_path": "/app/data",
      "http": true
    },
    {
      "name": "Postgres",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    },
    {
      "name": "Redis",
      "source": {
        "image": "redis:8.2.1"
      },
      "needs_volume": true,
      "volume_mount_path": "/data",
      "http": false
    }
  ],
  "required_inputs": [
    {
      "key": "TZ",
      "service": "Sub2API",
      "description": "Container timezone.",
      "secret": false,
      "strategy": "default",
      "default": "Asia/Shanghai"
    },
    {
      "key": "DATA_DIR",
      "service": "Sub2API",
      "description": "Persistent application data directory.",
      "secret": false,
      "strategy": "default",
      "default": "/app/data"
    },
    {
      "key": "REDIS_DB",
      "service": "Sub2API",
      "description": "Redis database index.",
      "secret": false,
      "strategy": "default",
      "default": "0"
    },
    {
      "key": "AUTO_SETUP",
      "service": "Sub2API",
      "description": "Run first-start setup and database migrations automatically.",
      "secret": false,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "JWT_SECRET",
      "service": "Sub2API",
      "description": "Random secret of at least 32 bytes for signing sessions.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "REDIS_HOST",
      "service": "Sub2API",
      "description": "Redis hostname from the Redis service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDIS_PORT",
      "service": "Sub2API",
      "description": "Redis port from the Redis service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "ADMIN_EMAIL",
      "service": "Sub2API",
      "description": "Administrator email used by the first-start setup.",
      "secret": false,
      "strategy": "ask_user"
    },
    {
      "key": "SERVER_HOST",
      "service": "Sub2API",
      "description": "Address Sub2API listens on inside the container.",
      "secret": false,
      "strategy": "default",
      "default": "0.0.0.0"
    },
    {
      "key": "SERVER_MODE",
      "service": "Sub2API",
      "description": "Run Sub2API in production mode.",
      "secret": false,
      "strategy": "default",
      "default": "release"
    },
    {
      "key": "DATABASE_HOST",
      "service": "Sub2API",
      "description": "PostgreSQL hostname from the Postgres service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DATABASE_PORT",
      "service": "Sub2API",
      "description": "PostgreSQL port from the Postgres service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DATABASE_USER",
      "service": "Sub2API",
      "description": "PostgreSQL username from the Postgres service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "ADMIN_PASSWORD",
      "service": "Sub2API",
      "description": "Administrator password used by the first-start setup.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "REDIS_PASSWORD",
      "service": "Sub2API",
      "description": "Redis password from the Redis service.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DATABASE_DBNAME",
      "service": "Sub2API",
      "description": "PostgreSQL database name from the Postgres service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DATABASE_SSLMODE",
      "service": "Sub2API",
      "description": "PostgreSQL SSL mode for private-network connections.",
      "secret": false,
      "strategy": "default",
      "default": "disable"
    },
    {
      "key": "REDIS_ENABLE_TLS",
      "service": "Sub2API",
      "description": "Enable TLS for the private Redis connection.",
      "secret": false,
      "strategy": "default",
      "default": "false"
    },
    {
      "key": "DATABASE_PASSWORD",
      "service": "Sub2API",
      "description": "PostgreSQL password from the Postgres service.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "TOTP_ENCRYPTION_KEY",
      "service": "Sub2API",
      "description": "Random 32-byte key used to encrypt TOTP secrets.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "SERVER_TRUSTED_PROXIES",
      "service": "Sub2API",
      "description": "Trusted private-network proxies used by Railway.",
      "secret": false,
      "strategy": "default",
      "default": "100.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.0/8,fc00::/7,fe80::/10,::1/128"
    },
    {
      "key": "SECURITY_TRUST_FORWARDED_IP_FOR_API_KEY_ACL",
      "service": "Sub2API",
      "description": "Use the client IP supplied by the trusted Railway edge proxy.",
      "secret": true,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "PGDATA",
      "service": "Postgres",
      "description": "Location where the database will be initialized",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres",
      "description": "Railway Private Domain Name.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres",
      "description": "Port to connect to Postgres.",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres",
      "description": "Required variable for Data panel",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres",
      "description": "Required variable for the data panel.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres",
      "description": "Required variable for Data panel",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres",
      "description": "Default database created when image is started.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres",
      "description": "URL to connect to Postgres database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres",
      "description": "User to connect to Postgres DB",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres",
      "description": "SSL certificate expiry in days.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres",
      "description": "Password to connect to DB",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "DATABASE_PUBLIC_URL",
      "service": "Postgres",
      "description": "Public URL to connect to Postgres database, used by the Data panel.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres",
      "description": "Allow Postgres to cleanly shut down",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "REDISHOST",
      "service": "Redis",
      "description": "Redis connection setting REDISHOST.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "REDISPORT",
      "service": "Redis",
      "description": "Redis connection setting REDISPORT.",
      "secret": false,
      "strategy": "default",
      "default": "6379"
    },
    {
      "key": "REDISUSER",
      "service": "Redis",
      "description": "Redis connection setting REDISUSER.",
      "secret": false,
      "strategy": "default",
      "default": "default"
    },
    {
      "key": "REDIS_URL",
      "service": "Redis",
      "description": "Connection string for connecting to redis using the private network",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDISPASSWORD",
      "service": "Redis",
      "description": "Redis connection setting REDISPASSWORD.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDIS_PASSWORD",
      "service": "Redis",
      "description": "Redis connection setting REDIS_PASSWORD.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "REDIS_PUBLIC_URL",
      "service": "Redis",
      "description": "Connection string for connecting to redis externally",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "sub2api-railway"
      }
    },
    "cli": "railway deploy --template sub2api-railway",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "6478776d-829b-4db6-9515-822e6475c2a5",
            "serializedConfig": {
              "buckets": {},
              "services": {
                "2004244a-2a90-44b3-bceb-c02484af195f": {
                  "icon": "https://demo.sub2api.org/logo.png",
                  "name": "Sub2API",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": "/health",
                    "restartPolicyType": "ALWAYS",
                    "healthcheckTimeout": 300,
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "repo": "https://github.com/wsbjj/sub2api_railway",
                    "branch": "codex/railway-deploy",
                    "rootDirectory": null
                  },
                  "variables": {
                    "TZ": {
                      "isOptional": true,
                      "description": "Container timezone.",
                      "defaultValue": "Asia/Shanghai"
                    },
                    "DATA_DIR": {
                      "isOptional": true,
                      "description": "Persistent application data directory.",
                      "defaultValue": "/app/data"
                    },
                    "REDIS_DB": {
                      "isOptional": true,
                      "description": "Redis database index.",
                      "defaultValue": "0"
                    },
                    "AUTO_SETUP": {
                      "isOptional": true,
                      "description": "Run first-start setup and database migrations automatically.",
                      "defaultValue": "true"
                    },
                    "JWT_SECRET": {
                      "isOptional": false,
                      "description": "Random secret of at least 32 bytes for signing sessions.",
                      "defaultValue": "{{JWT_SECRET}}"
                    },
                    "REDIS_HOST": {
                      "isOptional": false,
                      "description": "Redis hostname from the Redis service.",
                      "defaultValue": "${{Redis.REDISHOST}}"
                    },
                    "REDIS_PORT": {
                      "isOptional": false,
                      "description": "Redis port from the Redis service.",
                      "defaultValue": "${{Redis.REDISPORT}}"
                    },
                    "ADMIN_EMAIL": {
                      "isOptional": false,
                      "description": "Administrator email used by the first-start setup.",
                      "defaultValue": "{{ADMIN_EMAIL}}"
                    },
                    "SERVER_HOST": {
                      "isOptional": true,
                      "description": "Address Sub2API listens on inside the container.",
                      "defaultValue": "0.0.0.0"
                    },
                    "SERVER_MODE": {
                      "isOptional": true,
                      "description": "Run Sub2API in production mode.",
                      "defaultValue": "release"
                    },
                    "DATABASE_HOST": {
                      "isOptional": false,
                      "description": "PostgreSQL hostname from the Postgres service.",
                      "defaultValue": "${{Postgres.PGHOST}}"
                    },
                    "DATABASE_PORT": {
                      "isOptional": false,
                      "description": "PostgreSQL port from the Postgres service.",
                      "defaultValue": "${{Postgres.PGPORT}}"
                    },
                    "DATABASE_USER": {
                      "isOptional": false,
                      "description": "PostgreSQL username from the Postgres service.",
                      "defaultValue": "${{Postgres.PGUSER}}"
                    },
                    "ADMIN_PASSWORD": {
                      "isOptional": false,
                      "description": "Administrator password used by the first-start setup.",
                      "defaultValue": "{{ADMIN_PASSWORD}}"
                    },
                    "REDIS_PASSWORD": {
                      "isOptional": false,
                      "description": "Redis password from the Redis service.",
                      "defaultValue": "${{Redis.REDISPASSWORD}}"
                    },
                    "DATABASE_DBNAME": {
                      "isOptional": false,
                      "description": "PostgreSQL database name from the Postgres service.",
                      "defaultValue": "${{Postgres.PGDATABASE}}"
                    },
                    "DATABASE_SSLMODE": {
                      "isOptional": true,
                      "description": "PostgreSQL SSL mode for private-network connections.",
                      "defaultValue": "disable"
                    },
                    "REDIS_ENABLE_TLS": {
                      "isOptional": true,
                      "description": "Enable TLS for the private Redis connection.",
                      "defaultValue": "false"
                    },
                    "DATABASE_PASSWORD": {
                      "isOptional": false,
                      "description": "PostgreSQL password from the Postgres service.",
                      "defaultValue": "${{Postgres.PGPASSWORD}}"
                    },
                    "TOTP_ENCRYPTION_KEY": {
                      "isOptional": false,
                      "description": "Random 32-byte key used to encrypt TOTP secrets.",
                      "defaultValue": "{{TOTP_ENCRYPTION_KEY}}"
                    },
                    "SERVER_TRUSTED_PROXIES": {
                      "isOptional": true,
                      "description": "Trusted private-network proxies used by Railway.",
                      "defaultValue": "100.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.0/8,fc00::/7,fe80::/10,::1/128"
                    },
                    "SECURITY_TRUST_FORWARDED_IP_FOR_API_KEY_ACL": {
                      "isOptional": true,
                      "description": "Use the client IP supplied by the trusted Railway edge proxy.",
                      "defaultValue": "true"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>:8080": {
                        "port": 8080
                      }
                    }
                  },
                  "volumeMounts": {
                    "2004244a-2a90-44b3-bceb-c02484af195f": {
                      "mountPath": "/app/data"
                    }
                  }
                },
                "a189d360-2371-4a56-8399-d6f6a8e98911": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres",
                  "build": {},
                  "deploy": {
                    "requiredMountPath": "/var/lib/postgresql/data"
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Location where the database will be initialized",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "Railway Private Domain Name.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "Port to connect to Postgres.",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{ POSTGRES_USER }}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "Required variable for the data panel.",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Default database created when image is started.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "URL to connect to Postgres database.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "User to connect to Postgres DB",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": true,
                      "description": "SSL certificate expiry in days.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Password to connect to DB",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "DATABASE_PUBLIC_URL": {
                      "description": "Public URL to connect to Postgres database, used by the Data panel.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Allow Postgres to cleanly shut down",
                      "defaultValue": "60"
                    }
                  },
                  "volumeMounts": {
                    "a189d360-2371-4a56-8399-d6f6a8e98911": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  }
                },
                "bf1cbb39-1a7a-4da4-ac52-dd4c25856e2f": {
                  "icon": "https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg",
                  "name": "Redis",
                  "deploy": {
                    "startCommand": "/bin/sh -c \"rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH\""
                  },
                  "source": {
                    "image": "redis:8.2.1"
                  },
                  "variables": {
                    "REDISHOST": {
                      "isOptional": false,
                      "description": "Redis connection setting REDISHOST.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "REDISPORT": {
                      "isOptional": false,
                      "description": "Redis connection setting REDISPORT.",
                      "defaultValue": "6379"
                    },
                    "REDISUSER": {
                      "isOptional": false,
                      "description": "Redis connection setting REDISUSER.",
                      "defaultValue": "default"
                    },
                    "REDIS_URL": {
                      "isOptional": false,
                      "description": "Connection string for connecting to redis using the private network",
                      "defaultValue": "redis://${{ REDISUSER }}:${{ REDIS_PASSWORD }}@${{ REDISHOST }}:${{ REDISPORT }}"
                    },
                    "REDISPASSWORD": {
                      "isOptional": false,
                      "description": "Redis connection setting REDISPASSWORD.",
                      "defaultValue": "${{REDIS_PASSWORD}}"
                    },
                    "REDIS_PASSWORD": {
                      "isOptional": false,
                      "description": "Redis connection setting REDIS_PASSWORD.",
                      "defaultValue": "{{REDIS_PASSWORD}}"
                    },
                    "REDIS_PUBLIC_URL": {
                      "description": "Connection string for connecting to redis externally",
                      "defaultValue": "redis://default:${{ REDIS_PASSWORD }}@${{ RAILWAY_TCP_PROXY_DOMAIN }}:${{ RAILWAY_TCP_PROXY_PORT }}"
                    }
                  },
                  "volumeMounts": {
                    "bf1cbb39-1a7a-4da4-ac52-dd4c25856e2f": {
                      "mountPath": "/data"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "Sub2API",
      "method": "GET",
      "path": "/health",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 3,
    "needs_volume": true
  },
  "generated_at": "2026-10-30T16:14:57.468Z",
  "generator_version": "0.1.0"
}
