Packaging a product for provisioning
Provisioning & self-service follows what happens when a customer buys a tenant: an org at the identity provider, a matrix and a first admin in Archenstack. This page is what your own image has to carry so a machine will build that tenant's stack, and what your application should offer its customer afterwards.
This is what the platform needs from you. A standalone deployment has no orchestrator and no agent — you run your application yourself and nothing here applies. See Deployment modes.
Three files, at /deploy in your image
A machine learns everything about your product from the image you publish. Before it runs anything
it creates a stopped container, copies /deploy out of it, and removes it — so your instance
definition is read without your application ever starting.
| Path in the image | What it is |
|---|---|
/deploy/recipe.json | The instance definition: how containers and the compose project are named, the host pattern, which paths the app serves, the health target, the OIDC registration inputs, and where your data lives |
/deploy/instance-compose.yml | The compose file for ONE tenant. The machine does not edit it, which is why it is refused rather than corrected when it asks for too much |
/deploy/instance.env.template | The environment your instance starts from. Values the machine supplies — the tenant's slug, its ceilings, its secrets — are substituted into it |
All three are required. A missing one fails the provision loudly rather than building a tenant from assumptions.
What the compose file must declare
The machine refuses a stack that would be free to take it or to reach it, and the refusal lists every finding at once rather than one per attempt, so you fix the set in one pass instead of spending a provision per item.
Per service:
| Setting | Why it is required |
|---|---|
mem_limit, or deploy.resources.limits.memory | An unbounded service is killed when the machine runs out of memory, taking its tenant with it. TENANT_MEMORY_LIMIT is written into the instance's environment for this |
cpus, or deploy.resources.limits.cpus | An uncapped service is never killed for taking CPU — it slows every other tenant instead, and no health check reports that. TENANT_CPU_LIMIT is written in for this. cpu_shares does not satisfy it: a weight under contention is not a ceiling |
cap_drop: [ALL] | Then add back only what the service needs |
security_opt: ["no-new-privileges:true"] | Stops a process inside the container gaining privileges through a setuid binary |
pids_limit | A loop that forks exhausts the machine's process table and every tenant on it stops. The CPU ceiling does not bound this |
user, a non-root uid | A flaw in a service running as root starts from the most capable account there is. Your image's own files have to be readable by that uid |
logging.options.max-size | Output nobody reads fills the machine's disk and every tenant on it stops |
Your containers are also put on a network of their own, so one tenant cannot reach another's containers through Docker's DNS.
The ceilings have to add up to the plan
Each service being bounded is not the same as the stack fitting what the customer bought. Four bounded services, each given the whole plan, can consume four times it — so the sum is checked against the plan too.
A ceiling counts once per replica, because Docker applies it per container: deploy.replicas: 3
of a service declaring cpus: "0.5" runs three containers of half a core each and takes one and a
half. The refusal states the sum, the budget, and that a replica multiplies it.
Divide the plan's budget across your services rather than giving each one the whole of it.
Scaling inside one tenant
A plan sells cores and memory, not containers, so its budget is reached by using it rather than by dividing it. Most products scale inside one container — worker processes, a thread pool, a cluster module — which needs nothing from the platform at all: it is your image and your entrypoint, and it takes effect on the next provision or update.
deploy.replicas is also supported, counted against the plan, and routed to: the tenant's route
names one upstream per container of your app service, so three replicas take a third of the requests
each. With more than one upstream a request that reaches a failing replica is retried against
another rather than answered with a 502, and that replica is left out of the rotation for a while.
Two things to know before relying on it:
- the catch-all path is served by the machine's own shared frontend host, not by your containers, so it has no replicas;
- a service whose
container_nameyou fix cannot be scaled at all — Docker refuses to start a second container of it — so leave container naming to the compose project.
Beyond the plan's budget, a larger plan gives the tenant more on the machine it is already on, and a second machine is for when the plan's ceiling is itself the limit. Both are the platform operator's actions, not yours.
Declare every place you keep data
Every place your product keeps data gets a named backup and a restore of the same name. Both
are lists:
"backup": [
{ "name": "database", "container": "{project}-postgres-1",
"command": ["pg_dump", "-Fc", "-f", "/tmp/dump", "app_{slug_}"],
"artifactPath": "/tmp/dump" },
{ "name": "uploads", "container": "{project}-app-1",
"command": ["tar", "-cf", "/tmp/uploads.tar", "/data/uploads"],
"artifactPath": "/tmp/uploads.tar" }
],
"restore": [
{ "name": "database", "container": "{project}-postgres-1",
"command": ["pg_restore", "-d", "app_{slug_}", "/tmp/dump"],
"artifactPath": "/tmp/dump" },
{ "name": "uploads", "container": "{project}-app-1",
"command": ["tar", "-xf", "/tmp/uploads.tar", "-C", "/"],
"artifactPath": "/tmp/uploads.tar" }
]
The names match a copy's parts to the commands that put them back, so they must be present, distinct, and plain names. A part you can copy and cannot restore is refused, because a tenant that can be backed up and never moved is worse than one that says so: a move would otherwise bring up a stack with the right secrets and part of its data.
A tenant's copy is one artifact whatever number of parts it has — a restore has to put back a set taken at the same moment, and a copy per part makes a mismatched set possible. A copy carrying different parts than the product being built restores is refused when it arrives, naming what is missing and what is extra.
A product with no durable data of its own declares neither list. That is a real answer, reported as "nothing to copy" rather than as a failure.
Your application's own secrets arrive wrapped
Secrets generated for a tenant reach your instance wrapped, so taking the machine's disk yields no usable key. Your application unwraps them once at boot. That mechanism, and what to do when your image needs a secret the platform does not generate, is in Wrapped secrets.
What your application should offer its customer
Backups are the tenant's to turn on
Copies of a tenant's data are kept only once that tenant has agreed to it, and a tenant is provisioned with no decision recorded — which is read as off. So a product that shows its customer nothing about backups has customers with no backups.
Three calls, all under the client credentials registered for that tenant — the same authority your application already uses for its own status read:
| Call | What it answers |
|---|---|
GET /tenants/{slug}/status | backup_copies is on, paused or off, beside last_backup_at. One word, for a banner |
GET /tenants/{slug}/backups/consent | The whole decision: copies, decided (false when nobody has asked), when, by whom, and copies_held |
PUT /tenants/{slug}/backups/consent | {"copies": "on" | "paused" | "off"} |
decided is the field worth showing. copies: "off" with decided: false means nobody has asked
this customer yet, which is not the same as a customer who declined — and only the first of those
is worth prompting about.
Withdrawing takes a second answer, because the word has two readings and neither can be a default:
PUT /tenants/acme/backups/consent
{ "copies": "off", "held_copies": "delete" } // or "keep"
delete removes the copies already held; keep leaves them and stops adding to them. Sending off
without one is refused with a 409. paused is the middle answer: nothing new is taken, what is
held stays, and turning copies back on starts the next pass copying again.
Asking at the point of sale
If your pricing page is built with @archenstack/pricing-web, give <Pricing> the backupCopies
prop and it renders the question; the buyer's answer is recorded against their tenant the moment it
is built. A page that does not pass the prop asks nothing and records nothing, leaving the question
to your application later.
<Pricing
plans={plans}
orchestratorOrigin="https://orchestrator.example.com"
product="product-a"
backupCopies={{ note: "You can pause or stop them at any time." }}
/>
Checklist
-
/deploy/recipe.json,/deploy/instance-compose.ymland/deploy/instance.env.templateare all in the published image. - Every service bounds both memory and CPU, with a ceiling rather than a weight.
- Every service drops capabilities, refuses new privileges, bounds its pids, runs as a non-root uid, and caps its logs.
- The ceilings sum to the plan, counting each service once per replica.
- Every place you keep data has a
backupand arestoreof the same name — or neither list, if you keep none. - Your application unwraps its secrets at boot.
- Your application tells its customer whether backups are on, and lets them change it.
See also
- Provisioning & self-service — what happens before the stack is built.
- Wrapped secrets — how a tenant's secrets reach it, and how to unwrap.
- Isolating your own data by tenant — the application-level boundary inside your own schema, which is a different question from the machine-level one here.
- Deployment modes — the standalone alternative, where none of this applies.