2. Write your first spec
Start with no axes at all. A spec that only wraps Compose is already useful: it gives you a stable per-PR project name and the all-profiles teardown rule.
preview.yml:
version: 1stack: pr-${PR}
compose: file: docker-compose.preview.yml profiles: [backend, frontend]Three things are happening:
| Field | What it does |
|---|---|
stack: pr-${PR} |
the stack identity. Becomes the Compose project name (-p pr-123), and is exported to every hook as $STACK. |
compose.file |
passed as -f. |
compose.profiles |
up enables these; down enables all of them, always. Put every service behind a profile so a bare docker compose up starts nothing. |
Validate it
Section titled “Validate it”validate parses, resolves all interpolation, and reports what it found. It touches nothing.
$ PR=123 pstack validatestack: pr-123✓ spec parses — kind: isolated, 0 axis/axes, stack "pr-123" compose: docker-compose.preview.yml [backend, frontend] ! kind: isolated with no axes — nothing per-tenant is provisioned or verified, so this is just a compose project. If it is a host singleton, mark it `kind: shared` so `down` is guarded.The first line is the resolved identity. Read it — it is the single most common thing to get wrong.
The ! is the warning you should expect at this stage, and it says something true: with no axes
this is a Compose wrapper, and verify has nothing to check. It goes away when you add the first
axis in section 3. If this spec is not a per-PR stack but a host singleton — a shared database, a
queue cluster — mark it kind: shared instead, which is section 7.
Dry-run it
Section titled “Dry-run it”$ PR=123 pstack up --dry-runstack: pr-123 (dry-run)→ compose up (backend, frontend) [dry-run] compose up ✓ compose (compose)(-q pairs usefully with -n: it drops the header and the [dry-run] lines, leaving just the step
sequence. On its own -q only removes the stack: header.)
--dry-run prints each step in order and executes nothing. It is the fastest way to check axis
ordering. It does not echo the underlying shell command — for that, use -v on a real run
(section 4).
The unset-variable guard
Section titled “The unset-variable guard”Forget PR and you get a hard error, not a stack named pr-:
$ pstack validatepstack: stack: undefined variable(s) ${PR}. Pass them in the environment or under `env:` in the spec.$ echo $?3This is deliberate and it is load-bearing. pr- with PR unset is a name every PR shares, so
every PR would deploy into one stack and tear down each other’s resources — collision instead of
isolation. An empty string counts as undefined too (PR= pstack validate fails identically).