[ PROMPT_NODE_25306 ]
deployment-details
[ SKILL_DOCUMENTATION ]
# 部署详情
使用此参考资料进行服务发现、配置模式、快捷命令及处理常见问题。
## 服务发现
**列出所有服务:**
list_services()
返回所有包含 ID、名称、类型和状态的服务。
**获取特定服务详情:**
get_service(serviceId: "")
返回完整配置,包括环境变量和构建/启动命令。
**列出 PostgreSQL 数据库:**
list_postgres_instances()
**列出键值存储:**
list_key_value()
## 配置详情
### 环境变量
**所有环境变量必须在 render.yaml 中声明。**
**环境变量的三种模式:**
1. **硬编码值** (非敏感配置):
yaml
envVars:
- key: NODE_ENV
value: production
- key: API_URL
value: https://api.example.com
2. **数据库连接** (自动生成):
yaml
envVars:
- key: DATABASE_URL
fromDatabase:
name: postgres
property: connectionString
- key: REDIS_URL
fromDatabase:
name: redis
property: connectionString
3. **密钥** (由用户在仪表板中填写):
yaml
envVars:
- key: JWT_SECRET
sync: false
- key: API_KEY
sync: false
- key: STRIPE_SECRET_KEY
sync: false
完整的环境变量指南: [configuration-guide.md](configuration-guide.md)
### 端口绑定
**关键:** Web 服务必须绑定到 `0.0.0.0:$PORT` (而非 `localhost`)。Render 会设置 `PORT` 环境变量。
**Node.js 示例:**
javascript
const PORT = process.env.PORT || 3000;
app.listen(PORT, '0.0.0.0', () => {
console.log(`Server running on port ${PORT}`);
});
**Python 示例:**
python
import os
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
**Go 示例:**
go
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
http.ListenAndServe(":"+port, handler)
### 计划默认值
**除非用户另有指定,否则使用 `plan: free`。** 请参考 Render 定价以了解当前的限制和容量。
### 构建命令
**使用非交互式标志以防止构建挂起:**
- npm: `npm ci`
- yarn: `yarn install --frozen-lockfile`
- pnpm: `pnpm install --frozen-lockfile`
- bun: `bun install --frozen-lockfile`
- pip: `pip install -r requirements.txt`
- uv: `uv sync`
- apt: `apt-get install -y `
- bundler: `bundle install --jobs=4 --retry=3`
### 数据库连接
当服务连接到同一 Render 环境中的数据库时