deploy-render
暂无简介
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
03 SKILL.md 正文
Render 部署
适用场景
- 全栈 Web 应用:Node.js、Python、Go、Ruby、Rust 后端 + 数据库
- 静态站点:前端 SPA、文档站点
- 后台 Worker:异步任务处理、定时任务
- Docker 化应用:通过 Dockerfile 部署任意语言应用
- 需要托管 PostgreSQL/Redis 的场景
前置条件
- Render 账号:https://render.com
- 安装 Render CLI(可选,主要通过 render.yaml 蓝图管理)
- 项目代码托管在 GitHub/GitLab/Bitbucket(Render 通过 Git 集成部署)
部署方式
Render 支持两种部署方式:
- render.yaml 蓝图(推荐):基础设施即代码,一键创建所有服务和数据库
- Dashboard 手动创建:通过 Web 界面逐个创建服务
一、render.yaml 蓝图
render.yaml 放在项目根目录,定义所有基础设施。
完整示例(全栈应用)
services:
# 前端静态站点
- type: web
name: my-frontend
env: static
buildCommand: npm ci && npm run build
staticPublishPath: dist
routes:
- type: rewrite
source: /*
destination: /index.html
# 后端 API 服务
- type: web
name: my-api
env: node
buildCommand: npm ci && npm run build
startCommand: npm start
healthCheckPath: /health
envVars:
- key: NODE_ENV
value: production
- key: DATABASE_URL
fromDatabase:
name: my-db
property: connectionString
- key: API_KEY
sync: false # 需要在 Dashboard 手动设置
# 后台 Worker
- type: worker
name: my-worker
env: node
buildCommand: npm ci
startCommand: npm run worker
envVars:
- key: DATABASE_URL
fromDatabase:
name: my-db
property: connectionString
databases:
- name: my-db
databaseName: myapp
user: myapp
plan: free # free | starter | standard | pro
ipAllowList:
- source: 0.0.0.0/0
description: allow all (仅开发环境)
各类型服务配置
1. 静态站点
services:
- type: web
name: my-site
env: static
buildCommand: npm run build
staticPublishPath: dist
headers:
- path: /*
name: X-Frame-Options
value: DENY
2. Node.js Web 服务
services:
- type: web
name: my-api
env: node
plan: standard
buildCommand: npm ci && npm run build
startCommand: node dist/server.js
healthCheckPath: /health
autoDeploy: true
branch: main
numInstances: 1
3. Docker 服务
services:
- type: web
name: my-app
env: docker
dockerfilePath: ./Dockerfile
dockerContext: .
dockerCommand: ./start.sh
healthCheckPath: /health
4. Python Web 服务
services:
- type: web
name: my-api
env: python
buildCommand: pip install -r requirements.txt
startCommand: gunicorn app:app
healthCheckPath: /health
5. Go Web 服务
services:
- type: web
name: my-api
env: go
buildCommand: go build -o server
startCommand: ./server
healthCheckPath: /health
6. 后台 Worker
services:
- type: worker
name: my-worker
env: node
buildCommand: npm ci
startCommand: npm run worker
7. 定时任务(Cron Job)
services:
- type: cron
name: my-cron
env: node
schedule: "0 2 * * *" # 每天凌晨 2 点
buildCommand: npm ci
startCommand: npm run cron
数据库配置
databases:
- name: my-postgres
databaseName: myapp
user: myapp
plan: starter
version: "16"
ipAllowList:
- source: 10.0.0.0/8
description: internal
- name: my-redis
type: redis
plan: starter
maxmemoryPolicy: allkeys-lru
环境变量
envVars:
# 静态值
- key: NODE_ENV
value: production
# 从服务组同步(所有服务共享)
- key: SHARED_KEY
sync: true
value: some-value
# 从另一个服务获取
- key: API_URL
fromService:
type: web
name: my-api
property: host
# 从数据库获取连接串
- key: DATABASE_URL
fromDatabase:
name: my-db
property: connectionString
# 需要手动设置的密钥
- key: STRIPE_SECRET_KEY
sync: false
二、部署流程
通过 Git 自动部署
- 在 Render Dashboard 连接 Git 仓库
- Render 自动检测
render.yaml并创建服务 - 每次 push 到指定分支自动触发部署
通过 CLI 触发部署
# 安装 Render CLI
npm install -g render-cli
# 或 brew install render
# 登录(需要用户交互)
render login
# 触发部署
render services deploy <service-id-or-name>
# 查看部署状态
render services list-deploys <service-id-or-name>
通过 API 触发部署(备选)
如需直接调用 Render REST API,请在受信任的 CI 环境中使用官方 GitHub Action,详见下方 CI/CD 集成。
CI/CD 集成
GitHub Actions 触发部署
使用 Render 官方 GitHub Action 触发部署:
name: Deploy to Render
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
- name: Trigger Render Deploy
uses: renderinc/deploy-render-action@v1
with:
serviceId: ${{ secrets.RENDER_SERVICE_ID }}
apiKey: ${{ secrets.RENDER_API_KEY }}
需要的 Secrets:
RENDER_API_KEY:Render API Key(Account Settings → API Keys)RENDER_SERVICE_ID:服务 ID(Dashboard 服务页面 URL 中srv-xxx)
项目类型适配
| 项目类型 | env 类型 | buildCommand | startCommand |
|---|---|---|---|
| Next.js (Node) | node | npm ci && npm run build |
npm start |
| Vite 静态站点 | static | npm ci && npm run build |
- |
| Express API | node | npm ci |
npm start |
| Django | python | pip install -r requirements.txt |
gunicorn app:app |
| FastAPI | python | pip install -r requirements.txt |
uvicorn main:app |
| Gin (Go) | go | go build -o server |
./server |
| Docker 应用 | docker | (Dockerfile) | (Dockerfile CMD) |
检查清单
- [ ]
render.yaml放在项目根目录 - [ ] 所有服务的 buildCommand 和 startCommand 正确
- [ ] 数据库已在
databases中定义 - [ ] 环境变量已配置(敏感变量
sync: false) - [ ] healthCheckPath 已配置(Web 服务)
- [ ] 静态站点配置了 SPA rewrite 路由(如需要)
- [ ] CI/CD 中 Render API Key 和 Service ID 已配置
- [ ] 部署日志无错误,服务状态为 "Live"
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.