Skip to content
Back to skills

Ape Deploy

ASecurity

Deploy the product to a server: ape server setup on a plain Ubuntu server, the bucket for uploads and backups, the settings file (production or staging), ape deploy and what one deploy ships (the API, the console, the web app) and checks before it calls a release good (migrations that only add, every process steady, health), going back to the previous image, a failed first deploy, the first Owner, phone builds, and the job queue's numbers on /health.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
developmentrustgonodedockerapidatabase

Works with

  • api
  • mcp

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add BuffApe/BuffApe --skill ape-deploy --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ape Deploy?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ape Deploy
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/buffape-ape-deploy/badge)](https://www.skillsdirectory.com/skills/buffape-ape-deploy)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ape-deploy
description: "Deploy the product to a server: ape server setup on a plain Ubuntu server, the bucket for uploads and backups, the settings file (production or staging), ape deploy and what one deploy ships (the API, the console, the web app) and checks before it calls a release good (migrations that only add, every process steady, health), going back to the previous image, a failed first deploy, the first Owner, phone builds, and the job queue's numbers on /health."
---

# Deploying to a server

A person decides to deploy; an agent prepares and explains, and runs `ape deploy` only when the person asked for that deploy to that server (section 2). What only a person types stays theirs: the first Owner's password (section 4), the bucket's account. Never put a secret on a command line or in a commit.

## 1. Prepare the server, once (and again when settings or processes change)

1. A plain Ubuntu server (24.04 or later) you reach by SSH with a key, for this product alone: setup and deploy take its ports (80, 443, the web app's, the API's, Postgres, Redis) and setup its firewall and SSH settings, so both refuse a server that runs another product (another `/srv/<name>`), naming it.
2. **The bucket for uploads and backups**, made by a person (an agent can't open the account): an S3-compatible bucket at another provider than the server's, so backups are off-site (Cloudflare R2, Backblaze B2, Amazon S3 or another), and a key that can read, write, list and delete in it. Make the bucket first: nothing makes it. Setup checks it answers to the key before changing anything, as the API's `/health` will.
3. The settings file, `.env.production` by default (never committed): the bucket (`APE_S3_ENDPOINT`, its `https://` address, which is what to use for a bucket reached over the internet: nothing refuses `http://`, so a lab's bucket on your own network may use it, but its key and every backup then travel unencrypted; `APE_S3_BUCKET`; `APE_S3_ACCESS_KEY`; `APE_S3_SECRET_KEY`; `APE_S3_REGION` when the provider names one), sign-up's bot check (`TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY`: production refuses to start without them) and the product's own settings. `APE_APP_URL` is the web app's address: leave it out for `https://<address>:8443`, or name another host on this server (its DNS pointed here too).
   - **Staging or production:** `docs/ARCHITECTURE.md`, "Staging or production for a server of your own?" (`APE_ENV=staging` in its own file, `--env .env.staging`).
4. `pnpm ape server setup <user@server> --domain <name> --env <file>` (or `--network-only <address>` for a server only your network reaches; `-i <key>` as `ssh`). It makes the secrets the file lacks and adds them to it: keep a copy of the file offline.

Run setup again after changing the settings file or `processes` in `buffcore.config.ts`, or after an upgrade whose notes say so: until then `ape deploy` refuses, saying what differs.

## 2. Deploy

Before a release with migrations, run `ape backup test --migrations --json` in the next release's image on the production server: it rehearses pending migrations on the newest backup's scratch copy, reports only outcome, time and row counts, then drops it; exit 1 stops the release.

After switching to a database restored with `ape backup restore --into`, run `ape uploads orphans` to see which stored originals no row names: it never removes by itself.

`pnpm ape deploy <user@server>` ships the commit checked out (commit first: uncommitted files stay on your computer). `--json` prints one result line for tools. An agent deploys through the `ape mcp` tool `server_deploy` only when the person asked for that deploy to that server: it reaches the product's users.

**One deploy ships the whole app, and one rollback takes it all back:**

| Part | Where it lives |
|---|---|
| The API (`/v1`, `/health`, `/mcp`) | `https://<address>` |
| The admin console | `https://<address>`, the same address |
| The web app (`app/` or `apps/app/`) | `APE_APP_URL`, by default `https://<address>:8443`; it calls the API at `https://<address>` |

The server's Caddy serves all three with HTTPS. The web app is built in the image as `ape build web` builds it; you don't build or serve it yourself.

What it does, in order, stopping at the first failure:
Before building, deploy refuses tracked changes, checks Change and Task trailers on each change branch's own commits through its named merge on main's first-parent history since the server's deployed commit (no history on a first deploy), then runs the product's `pnpm lint`; a failure refuses with exit 2, while `--local` keeps its signed approval check.
The trailer check follows `--no-ff` merges of change branches; fast-forward, squash and rebase merges, or a deploy straight from a change branch, aren't checked.
1. Builds one image from the commit. The image names no server: the console reads its addresses from `/console.json` when it starts, and deploy writes the server's API address into the web app's files, so the same image runs on staging and production.
2. Asks the running image what it reads (`ape migrate reads`), and backs up.
3. **Checks the migrations** with the new image (`ape migrate check`): a pending migration that drops or renames a table or column the running release reads, narrows its type or makes it required stops the deploy, nothing migrated (`refused`).
4. Migrates, copies the console's and the web app's files, restarts (each old process stopped gracefully, with 30 seconds to finish), checks `/health`, then watches every process (the API, each Node process, each container) for 15 seconds: each must be running, healthy if it has a health check, and not restarting.
5. If the new release fails any of that, the previous image runs again, with its console and web app (`rolled_back`), and is checked the same way.

## 3. When it doesn't go through

- **`refused`, a migration:** the output names it and what it takes away. Ship the change that stops reading it first; drop it in a later change (the `ape-migration` skill).
- **`refused`, setup again:** the server runs other processes than `buffcore.config.ts` declares, or its web server doesn't serve the web app yet: run `ape server setup` there again, then deploy.
- **`rolled_back`:** the output names the process that failed. Read its logs on the server: `ssh <server> sudo docker compose -f /srv/<product>/compose.yml logs <process>`. Fix, commit, deploy again.
- **`failed` on a first deploy:** there was no previous image, so nothing of it is left running or served; its logs are in `/srv/<product>/failed-deploy.log` (`ssh <server> sudo cat …`). `/health` saying `"storage": "down"` means the bucket doesn't answer (section 1). Fix, commit, deploy again: it is a first deploy again.
- **`failed` after a rollback:** the previous image doesn't run either. Tell a person at once.

## 4. After the first deploy

- **The first Owner, then an email service,** once: the product's `README.md`, "On a server" (deploy also prints the Owner's command). The person types the Owner's password at its prompt; an agent never asks for it or sets one. Until an email service is on, nobody can finish signing up: `docs/IDENTITY_ACCESS.md`, the emailed code.
- **Sample data on staging only:** `ssh <server> sudo docker compose -f /srv/<product>/compose.yml run --rm ape seed <scenario>`. Production refuses it.
- **Phone builds** call the same API: `APE_API_URL=https://<address> pnpm ape build android` (and `ios`). With `--network-only`, a phone trusts the server only once it trusts the root certificate setup names.
- **Watching it:** `https://<address>/health` answers what it checked, the release, and the job queue's numbers (`queue: { waiting, oldestWaitSeconds }`): jobs waiting long means the workers fall behind (more `count` for the worker, a `hosting` change).

Build once in a clean product checkout with `pnpm ape build server --json` (`--platform <os/arch>`, default `linux/amd64`): it uses deploy's exact image builder, tags the product and each container with a Dockerfile by the full commit SHA, ships nothing, and prints the product's and containers' image IDs. Move the images to each server yourself and run `ape catalog verify` on that commit before approval. A person signs the approval naming the product image's `id` and `commit` from the JSON line; on staging, then production, run that same image with `ape deploy --local <image> --approval <file>`. It never rebuilds. Registries, hosting and scaling remain a cloud's parts; the output and exit codes are in `docs/ARCHITECTURE.md`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.