deployment-guide
Skill30 starsChanged 53 days agoMITView on GitHub
Vercel frontend + Railway/Fly.io backend deployment, env vars, health checks. Use when deploying a Next.js frontend to Vercel or a NestJS backend to Railway or Fly.io, or troubleshooting a deployment issue.
- Pipes a download into a shell
- Reads credentials
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- thensls/nsls-builder-toolkittheir own version, first seen Nov 8, 2026
- Azure-Samples/art-voice-agent-acceleratortheir own version, first seen Oct 8, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- Azure-Samples/art-voice-agent-accelerator★ 74same name
- thensls/nsls-builder-toolkit★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- claude/CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- api-design-patternsSkill
- auth-patternsSkill
- backend-dev-guidelinesSkill
- brainstormingSkill
- code-review-patternsSkill
- docker-patternsSkill
- docx-officialSkill
- frontend-designSkill
- github-actionsSkill
- git-workflowSkill
- nestjs-patternsSkill
- nextjs-app-routerSkill
- pdf-officialSkill
- pptx-officialSkill
- prisma-workflowSkill
- prompt-engineeringSkill
- react-best-practicesSkill
- security-checklistSkill
- skill-creatorSkill
- software-architectureSkill
- systematic-debuggingSkill
- tailwind-patternsSkill
- test-driven-developmentSkill
- typescript-patternsSkill
- webapp-testingSkill
- web-design-guidelinesSkill
- xlsx-officialSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 358
Never deploy with NODE_ENV=development in production
- Distinctive: line 359
Never use the same JWT secret across environments
- Distinctive: line 360
Never skip health check endpoints — platforms use them for traffic routing
- Distinctive: line 361
Never run database migrations during app startup — run them as a separate step
- Very specific: line 362
Never put NEXT_PUBLIC_* values that are secrets — they're bundled into the browser
- Distinctive: line 363
Never deploy without verifying the build passes CI first
- Very specific: line 364
Never use 0.0.0.0 as CORS_ORIGINS in production — specify exact origins
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Deployment Guide
Frontend — Vercel
Setup
# Install Vercel CLI
npm i -g vercel
# Login
vercel login
# Link project (run once in the project root)
vercel link
# Deploy to preview
vercel
# Deploy to production
vercel --prodvercel.json
{
"framework": "nextjs",
"buildCommand": "pnpm run build",
"installCommand": "pnpm install --frozen-lockfile",
"outputDirectory": ".next",
"regions": ["iad1"],
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "X-XSS-Protection", "value": "1; mode=block" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }
]
},
{
"source": "/api/(.*)",
"headers": [
{ "key": "Cache-Control", "value": "no-store, max-age=0" }
]
},
{
"source": "/_next/static/(.*)",
"headers": [
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
]
}
],
"rewrites": [
{
"source": "/api/:path*",
"destination": "https://api.example.com/api/:path*"
}
]
}Vercel Environment Variables
# Set env vars per environment
vercel env add NEXT_PUBLIC_API_URL production
vercel env add NEXT_PUBLIC_API_URL preview
vercel env add NEXT_PUBLIC_API_URL development
# Pull to local .env.local
vercel env pull .env.localnext.config.ts for Production
import type { NextConfig } from 'next'
const config: NextConfig = {
output: 'standalone',
// Strict mode catches side effects in development
reactStrictMode: true,
// Image optimization
images: {
domains: ['cdn.example.com', 'avatars.githubusercontent.com'],
formats: ['image/avif', 'image/webp'],
},
// Bundle analyzer (install @next/bundle-analyzer)
// ...(process.env.ANALYZE === 'true' && require('@next/bundle-analyzer')())
// Security headers
async headers() {
return [
{
source: '/(.*)',
headers: [
{ key: 'X-DNS-Prefetch-Control', value: 'on' },
],
},
]
},
// Redirects
async redirects() {
return [
{ source: '/old-path', destination: '/new-path', permanent: true },
]
},
}
export default configBackend — Railway
Setup
# Install Railway CLI
npm i -g @railway/cli
# Login
railway login
# Initialize (run in project root)
railway init
# Deploy
railway up
# Open dashboard
railway open
# View logs
railway logs
# Run commands in service
railway run pnpm run migration:runrailway.json
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"dockerfilePath": "apps/api/Dockerfile"
},
"deploy": {
"startCommand": "node dist/main",
"healthcheckPath": "/health/liveness",
"healthcheckTimeout": 30,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 3
}
}Required Environment Variables (Railway)
# Set via Railway dashboard or CLI
DATABASE_URL = ${{Postgres.DATABASE_URL}} # Railway managed Postgres
REDIS_URL = ${{Redis.REDIS_URL}} # Railway managed Redis
NODE_ENV = production
PORT = ${{PORT}} # Railway injects this
JWT_SECRET = <generate: openssl rand -base64 32>
CORS_ORIGINS = https://your-app.vercel.app
LOG_LEVEL = infoBackend — Fly.io (Alternative)
Setup
# Install flyctl
curl -L https://fly.io/install.sh | sh
# Login
fly auth login
# Launch app (creates fly.toml)
fly launch --name my-api --region iad --no-deploy
# Deploy
fly deploy
# Scale
fly scale count 2
fly scale memory 512
# View logs
fly logs
# SSH into instance
fly ssh consolefly.toml
app = "my-api"
primary_region = "iad"
[build]
dockerfile = "apps/api/Dockerfile"
[env]
NODE_ENV = "production"
PORT = "8080"
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
[http_service.concurrency]
type = "connections"
hard_limit = 200
soft_limit = 150
[[vm]]
memory = "512mb"
cpu_kind = "shared"
cpus = 1
[checks]
[checks.health]
grace_period = "30s"
interval = "15s"
method = "GET"
path = "/health/liveness"
port = 8080
timeout = "5s"
type = "http"Health Check Endpoints
// health/health.controller.ts — must respond before traffic is routed
@Controller('health')
export class HealthController {
constructor(
private health: HealthCheckService,
private db: TypeOrmHealthIndicator,
) {}
// Liveness: is the process running?
@Get('liveness')
liveness() {
return { status: 'ok', timestamp: new Date().toISOString() }
}
// Readiness: can we serve traffic?
@Get('readiness')
@HealthCheck()
readiness() {
return this.health.check([
() => this.db.pingCheck('database', { timeout: 3000 }),
])
}
// Full check: all dependencies
@Get()
@HealthCheck()
full() {
return this.health.check([
() => this.db.pingCheck('database'),
])
}
}Database Migrations on Deploy
// src/cli.ts — run as a separate Railway service or pre-deploy command
import { NestFactory } from '@nestjs/core'
import { MigrationModule } from './migration/migration.module'
async function runMigrations() {
const app = await NestFactory.createApplicationContext(MigrationModule)
const dataSource = app.get(DataSource)
console.log('Running migrations...')
const migrations = await dataSource.runMigrations()
console.log(`Ran ${migrations.length} migrations`)
await app.close()
process.exit(0)
}
runMigrations().catch(err => {
console.error('Migration failed:', err)
process.exit(1)
})// package.json
{
"scripts": {
"migration:run": "ts-node src/cli.ts",
"start:prod": "node dist/main"
}
}Zero-Downtime Deployments
# Railway: automatic rolling deployments (no config needed)
# Fly.io: rolling deployments with health checks
# Ensure your app handles SIGTERM gracefully// main.ts — graceful shutdown
async function bootstrap() {
const app = await NestFactory.create(AppModule)
app.enableShutdownHooks()
await app.listen(process.env.PORT ?? 3000)
// Log when server is ready
console.log(`API running on port ${process.env.PORT ?? 3000}`)
}Environment Checklist
Production Environment Variables Checklist:
□ NODE_ENV=production
□ DATABASE_URL (managed service with connection pooling)
□ REDIS_URL (if using caching/sessions)
□ JWT_SECRET (min 32 chars, random)
□ CORS_ORIGINS (exact frontend domains, no wildcards)
□ LOG_LEVEL=info (not debug)
□ PORT (injected by platform)
Frontend:
□ NEXT_PUBLIC_API_URL (production backend URL)
□ No secrets in NEXT_PUBLIC_* vars (they're exposed to browser)Forbidden Patterns
- Never deploy with
NODE_ENV=developmentin production - Never use the same JWT secret across environments
- Never skip health check endpoints — platforms use them for traffic routing
- Never run database migrations during app startup — run them as a separate step
- Never put
NEXT_PUBLIC_*values that are secrets — they're bundled into the browser - Never deploy without verifying the build passes CI first
- Never use
0.0.0.0asCORS_ORIGINSin production — specify exact origins
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

