Stack
A named group of briqs that share a private network.
A stack groups briqs inside a team. Briqs in a stack share a private network and find each other by name, which is how a multi-briq recipe (Redis and its dashboard, an app and its database) wires itself up.
Using one
briq_run creates the stack on first use. Without stack the briq is in no stack: default is not
a group, and each such briq has a network of its own. A recipe of several briqs gets a stack named
after it instead. To group briqs, name the stack. A briq in default that uses {{briq:NAME}} in an
env value is refused (validation, 400): the address would not resolve from its own network.
briq run postgres --stack checkout
briq run redis --stack checkout
briq run ghcr.io/acme/checkout-api:pr-412 --stack checkout --port 3000 \
--env REDIS_HOST='{{briq:redis}}'briq_run({ recipe: "postgres", stack: "checkout" })
briq_run({ recipe: "redis", stack: "checkout" })
briq_run({ image: "ghcr.io/acme/checkout-api:pr-412", stack: "checkout", ports: [3000],
env: { REDIS_HOST: "{{briq:redis}}" } })curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"recipe": "postgres", "stack": "checkout", "wait": true}'
curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"recipe": "redis", "stack": "checkout", "wait": true}'
curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"spec": {
"name": "checkout-api",
"image": "ghcr.io/acme/checkout-api:pr-412",
"ports": [
3000
],
"env": {
"REDIS_HOST": "{{briq:redis}}"
}
},
"stack": "checkout",
"wait": true
}'Reaching another briq
- Recipe outputs already carry the right address: pass
DATABASE_URLto another briq as is. {{briq:<name>}}in anenvvalue becomes the address of the briq with that name in the same stack. The briq waits for it to be running before it starts. It works in plain values, not inside a secret'svalue: put the address in a plain variable and the password in a secret.
These addresses only resolve inside the stack. From outside, use briq_exec, or briq_expose an
HTTP port.
Move a briq
briq move bq_7kq2m9x1p4ab checkout
briq move bq_7kq2m9x1p4ab --outbriq_move({ briq: "bq_7kq2m9x1p4ab", stack: "checkout" })
briq_move({ briq: "bq_7kq2m9x1p4ab", stack: null })curl -X PATCH https://api.briq.cloud/v1/briqs/bq_7kq2m9x1p4ab \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"stack": "checkout"}'
curl -X PATCH https://api.briq.cloud/v1/briqs/bq_7kq2m9x1p4ab \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"stack": null}'stack is a name (a new name makes the stack) or an id. null, or default, takes the briq out
of its stack, and is refused when its env uses {{briq:NAME}}. The briq keeps its disk, name and
URLs. What it costs depends on the case:
| Case | What happens | Downtime |
|---|---|---|
| A briq alone joins a new stack, or leaves one and is the last in it | Renamed in place | None. Same address |
| A running briq joins a stack that has briqs, or leaves one that keeps some | Stopped and started on the new network (restarted: true) | Yes. Processes start over, the private IP changes |
| A stopped briq joins or leaves | Takes the new network at its next start | None |
| The stack's briqs run on another host | Refused (invalid_state, 409) | Make the briq again in the stack |
A moved briq keeps the internal host name it was made with. Reach it through {{briq:<name>}} or a
recipe output, which hold that stored address; a host name you build from the briq's name may not
resolve.
Briqs left in the old stack no longer reach it. A briq whose name the target stack already has is refused. A briq that uses a team secret moves too: it joins the credential gateway of the stack it moves to, and the move restarts it.
To group briqs made apart, move the first into a new stack (free), then create the next ones in it:
briq move bq_7kq2m9x1p4ab checkout
briq run redis --stack checkoutbriq_move({ briq: "bq_7kq2m9x1p4ab", stack: "checkout" })
briq_run({ recipe: "redis", stack: "checkout" })curl -X PATCH https://api.briq.cloud/v1/briqs/bq_7kq2m9x1p4ab \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"stack": "checkout"}'
curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"recipe": "redis", "stack": "checkout", "wait": true}'Isolation
A team's briqs are on private networks that no other team shares. Briqs of one stack reach each other. Count on nothing more: depending on where the team runs, a briq in another stack, or in no stack, may not be reachable. A stack is a network boundary, not a security boundary for what a team holds: every briq of a team is the same customer's.