返回提示词目录第 1383 页

搭建拉取请求预览环境

为每个拉取请求设计隔离预览环境,生成部署与自动清理配置,并梳理数据隔离和成本控制。

完整提示词

<context>
You set up an isolated, disposable environment for every pull request so reviewers, designers and QA can click through the change before merge. Previews go wrong in four ways: they share a database and one PR's migration breaks everyone else's preview; they get real customer data or production secrets; they are never torn down, so the bill grows with every forgotten branch; and they take so long to come up that nobody waits for them.

Stack: {{stack}}
Hosting: {{hosting}}
</context>

<task>
{{#constraints}}
<constraints_given>
{{constraints}}
</constraints_given>
{{/constraints}}

1. Design: what runs per PR (everything, or only the changed services with the rest pointing at a shared staging), naming (`pr-<number>`), isolation (namespace, project, app or compose project per PR), and the URL scheme (`pr-123.preview.<domain>` with a wildcard DNS record and certificate). Choose the lightest option the hosting supports and say why.
2. Lifecycle: create or update on PR opened and on each push; post or update one PR comment with the URL, commit and status; destroy on PR closed or merged; a scheduled cleanup job that removes previews whose PR is closed or idle beyond a set number of days, as a safety net for missed events. Builds reuse the CI image cache so a preview is up within about 10 minutes.
3. Data: a database per preview created from migrations plus a seed script with synthetic data, or a branchable or template database if the host supports it; never a copy of production unless it is anonymised by a tested process. Migrations run per preview; say how a destructive migration on one PR stays isolated.
4. Secrets: preview-only credentials, sandbox or test-mode keys for third parties, a separate auth tenant or test users, and no production secrets in preview jobs. Pull requests from forks get no secrets and no preview by default.
5. Access: previews behind authentication or an IP or SSO gate so unreleased features and test data are not public; robots blocked.
6. Write the config for the hosting and CI: the deploy job, the comment step, the destroy job and the scheduled cleanup.
7. Cost controls: a cap on concurrent previews, small instance sizes, scale-to-zero or sleep after inactivity, time-to-live, and a monthly cost estimate formula using the user's numbers (open PRs x hours alive x unit cost) with placeholders where prices are unknown.
</task>

<constraints>
- Use the stack and hosting given; do not switch platforms. If a part cannot run per PR, say what it points to instead and the risk.
- Never invent prices; give the formula and placeholders, and say where to check current pricing.
- Teardown must be automatic and idempotent; a preview that fails to deploy still gets cleaned up.
- If required information (CI system, domain, database) is missing, mark it as [X] and list it under Open questions.
</constraints>

<output_format>
## Design
Bullets plus a small diagram in text.
## Lifecycle
Table: event | action | job.
## Data and secrets
Bullets.
## Config
Fenced blocks for each job or file.
## Cost controls
Bullets and the estimate formula.
## Limits and risks
Bullets.
## Open questions
Bullets, or "None".
</output_format>

可替换内容

  • {{stack}}
  • {{hosting}}
  • {{#constraints}}
  • {{constraints}}
  • {{/constraints}}
  • [X]

分类与标签

编程开发、预览部署、持续集成、环境隔离、自动清理、成本控制

前往 AI 图片创作