operations.do · One command line for deploying, hardening and running your servers — driven by one .operationsdorc per project.
operationsdo is the command line for operations.do. It deploys a docker
compose app to a DigitalOcean droplet, hardens and verifies that droplet, and manages DNS, GitLab CI
and the app's operations.do client — all from one .operationsdorc file in the project. Compose
files, env files, deploy paths and service names are all configurable; nothing is tied to one project.
macOS and Linux (Manjaro/Arch, Debian/Ubuntu, Fedora). The CLI is installed from GitHub with pipx; it is not on PyPI.
curl -fsSL https://raw.githubusercontent.com/pamfilico/operationsdo-cli/main/install.sh | bashThe installer needs Python 3.10+, git and pipx. When one is missing it installs them with your OS's
package manager (sudo asks for your password) and puts pipx's bin directory on your PATH (pipx ensurepath).
--no-prerequisites makes it only say what is missing. What it runs:
| OS | Prerequisites |
|---|---|
| macOS | brew install python pipx git |
| Manjaro / Arch | sudo pacman -S --needed --noconfirm python python-pipx git |
| Debian / Ubuntu | sudo apt-get install -y python3 pipx git |
| Fedora | sudo dnf install -y python3 pipx git |
It ends by running operationsdo doctor, which checks the rest of the machine (Docker and its daemon,
compose, buildx, ssh, the Postgres client tools, Claude Code, a DigitalOcean token, the rc's operations.do)
and prints the install command for whatever is missing, for your OS. Run it again any time.
- Upgrade:
operationsdo update(--checkonly looks;--version v0.46.0installs that release). Once a day an interactive command also says when a newer release exists;OPERATIONSDO_NO_UPDATE_CHECK=1turns that off (it is always off in CI). - Pin a release:
curl -fsSL …/install.sh | bash -s -- --version v0.46.0, orpipx install --force "git+https://github.com/pamfilico/operationsdo-cli.git@v0.46.0". - From a checkout:
./install.sh --local. Remove:pipx uninstall operationsdo-cli. Releases: CHANGELOG.md.
Developing the CLI itself: CONTRIBUTING.md. Security reports: SECURITY.md.
cd my-project # a repo with a docker compose app
$EDITOR .operationsdorc # see Configuration below
operationsdo droplet ping # can it reach the droplet over SSH?
operationsdo stack deploy --registry # deploy the compose stack
operationsdo droplet verify # containers, HTTP, security baselineDeploys, hardening and verification need only the rc and SSH access to the droplet. Commands under
client, gitlab, app and do dns go through operations.do and need its
API key in the rc (OPERATIONS_API_KEY). do apps and do databases call DigitalOcean directly
(see DigitalOcean API token).
Commands are grouped by what they act on: operationsdo <namespace> <command>. Every command has
--help.
| Namespace | Acts on | Commands |
|---|---|---|
droplet |
the rc's droplet, and droplets account-wide | verify, ping, status, capacity, ssh, exec, logs, setup, setup-key, harden, scan, block-ip, ssh-password, rotate-key, registry-login, check-docker, certs, find-certs, cleanup, preflight · list, sizes, create, destroy, reap |
stack |
the app's compose stack on that droplet | deploy, restart, start, sync, upload-env, rollback, release, build-push, transfer-images, rotate-env |
do |
DigitalOcean account resources | machines, snapshots, databases, redis, spaces, dns, apps, appspec |
gitlab |
the project's GitLab side, through operations.do (no GitLab token in the rc) | status, health, vars, pipelines, mrs, branches, runner, pages, webhook, deploy-tokens, connectors, bind, unbind, clients, adopt, ci-vars, upsert-var, compare-var, mask-vars, protect-branch, schedule-security, check-repo, init |
smtp2go |
SMTP2GO keys held by operations.do: accounts, sub-accounts, sender domains, SMTP users (read-only) | list, add, show, domains, sync, rotate, rename, activate, deactivate, remove |
client |
the app's operations.do client and its API keys | list, tree, create, set-parent, move, push, pull, status, keys, rotate-keys, key (grant, revoke-scope, list) |
app |
one app by its operations.do identity, prod or dev | logs, containers, health, evidence, spaces |
run |
the app's local stack, from an rc section | operationsdo run --dev · --staging-local · --<section> |
rc |
the .operationsdorc file itself |
show, list, keys, health, describe, stamp |
health |
is this repo's setup sound | rc, droplet (no subject: both) |
doctor |
is this machine ready: tools installed, and how to install what is missing | — |
update |
upgrade operationsdo itself to the latest release | --check, --version |
cicd |
which CI/CD steps the project runs ([cicd] in the rc) |
status, apply |
crypto |
the encryption key for credentials stored at rest | new-key, install-master, status, audit, rotate, rotate-key, retire-key |
queue |
work and dead-letter queues on a Redis/Valkey cluster | list, export |
fleet |
every droplet on the account: verify + scan each | — |
api |
the operations.do API itself | health, droplets |
Older flat names (operationsdo deploy, operationsdo verify, …) still work as hidden aliases and
print the new path once; OPERATIONSDO_NO_RENAME_HINT=1 silences that.
operationsdo reads a .operationsdorc file from the current working directory. This is an INI-style file parsed with Python's configparser.
When you run operationsdo --target <name>, the tool looks for config files in this order:
- Explicit path —
operationsdo --config /path/to/file(highest priority) - Target-specific file —
.operationsdorc.<target>(e.g..operationsdorc.staging) - Default file —
.operationsdorc
This means you can organize config in two ways:
One .operationsdorc with [production], [staging], etc. sections:
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/yourrepo.git
GITLAB_BRANCH=master
COMPOSE_FILE=docker-compose.ocean.yml
COMPOSE_FILE_REGISTRY=docker-compose.ocean-image.yml
ENV_FILE=.env
GITLAB_REGISTRY_USER=youruser
[images]
frontend = frontend/Dockerfile.prod : frontend
backend = backend/Dockerfile : backend
worker = backend/Dockerfile.worker : backend
[production]
DROPLET_IP=123.45.67.89
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/yourapp
ENVIRONMENT=production
[staging]
DROPLET_IP=123.45.67.90
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/staging.pem # gitignored
DEPLOY_PATH=/opt/yourapp-staging
ENVIRONMENT=stagingoperationsdo stack deploy # uses [production]
operationsdo --target staging stack deploy # uses [staging].operationsdorc.production # plain KEY=VALUE or INI
.operationsdorc.staging
.operationsdorc.dev
operationsdo stack deploy # finds .operationsdorc.production
operationsdo --target staging stack deploy # finds .operationsdorc.staging
operationsdo --target dev droplet status # finds .operationsdorc.devEach file can be a simple flat KEY=VALUE list — no section headers needed.
A base .operationsdorc with shared defaults and a .operationsdorc.staging override for staging-specific config.
These files contain credentials. Add to your .gitignore:
.operationsdorc
.operationsdorc.*
If a config file has no [section] headers, it is treated as [DEFAULT]. This means an existing .env file works if you rename/copy it (or point to it with --config).
The [images] section tells operationsdo stack build-push which Docker images to build and where their Dockerfiles live. This replaces the old hardcoded service list and makes the CLI work with any project structure.
[images]
service_name = dockerfile_path : context_pathEach line defines one image to build:
| Part | Description |
|---|---|
service_name |
Name used in the registry tag (e.g. frontend → registry.../frontend:latest) |
dockerfile_path |
Path to the Dockerfile, relative to the project root |
context_path |
Docker build context directory, relative to the project root |
The image tag is derived automatically from GITLAB_REPO_URL:
https://gitlab.com/youruser/myproject.git
→ registry.gitlab.com/youruser/myproject/<service_name>:latest
operationsdo stack build-pushreads the[images]section from.operationsdorc(required)- For each service, it runs
docker build --platform linux/amd64locally, thendocker push - ARG values declared in the Dockerfile are auto-detected and filled from config
A typical web app with frontend, backend, and background worker:
myproject/
├── frontend/
│ ├── Dockerfile.prod
│ └── ...
├── backend/
│ ├── Dockerfile
│ ├── Dockerfile.worker
│ └── ...
├── docker-compose.ocean.yml # build mode
├── docker-compose.ocean-image.yml # registry pull mode
└── .operationsdorc
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/myproject.git
GITLAB_BRANCH=master
COMPOSE_FILE=docker-compose.ocean.yml
COMPOSE_FILE_REGISTRY=docker-compose.ocean-image.yml
ENV_FILE=.env.do
GITLAB_REGISTRY_USER=youruser
[images]
frontend = frontend/Dockerfile.prod : frontend
backend = backend/Dockerfile : backend
worker = backend/Dockerfile.worker : backend
[production]
DROPLET_IP=123.45.67.89
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/myproject
# ... app env vars ...The corresponding docker-compose.ocean-image.yml uses pre-built images:
services:
frontend:
image: registry.gitlab.com/youruser/myproject/frontend:latest
backend:
image: registry.gitlab.com/youruser/myproject/backend:latest
worker:
image: registry.gitlab.com/youruser/myproject/worker:latestBuild and deploy:
operationsdo stack build-push # build all 3 images locally, push to registry
operationsdo stack deploy --registry # deploy on droplet using pre-built imagesA larger app with separate AI microservices — backend and backend-worker share a Dockerfile but the build context is the repo root (because Dockerfile references files outside backend/):
myapp/
├── frontend/
│ └── Dockerfile
├── backend/
│ └── Dockerfile
├── aiservice/
│ └── Dockerfile
├── docker-compose.ocean.yml
├── docker-compose.ocean-image.yml
└── .operationsdorc
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/myapp.git
GITLAB_BRANCH=develop
COMPOSE_FILE=docker-compose.ocean.yml
COMPOSE_FILE_REGISTRY=docker-compose.ocean-image.yml
ENV_FILE=.env.ocean
GITLAB_REGISTRY_USER=youruser
ROUTING_MODE=path
[images]
frontend = frontend/Dockerfile : frontend
backend = backend/Dockerfile : .
backend-worker = backend/Dockerfile : .
aiservice = aiservice/Dockerfile : aiservice
aiservice-worker = aiservice/Dockerfile : aiservice
[production]
DROPLET_IP=203.0.113.10
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/myapp
# ... app env vars ...Key points:
backendandbackend-workeruse the same Dockerfile but produce separate images. The compose file overrides the command for the worker (python -u worker.py).- Context is
.(repo root) for backend because the Dockerfile copies files from the parent directory. aiserviceandaiservice-workerfollow the same pattern — same Dockerfile, different runtime commands.- All 5 images get their own registry tag:
registry.../myapp/frontend:latest,registry.../myapp/backend:latest, etc.
The corresponding docker-compose.ocean-image.yml:
services:
frontend:
image: registry.gitlab.com/youruser/myapp/frontend:latest
backend:
image: registry.gitlab.com/youruser/myapp/backend:latest
backend-worker:
image: registry.gitlab.com/youruser/myapp/backend-worker:latest
command: python -u worker.py
aiservice:
image: registry.gitlab.com/youruser/myapp/aiservice:latest
aiservice-worker:
image: registry.gitlab.com/youruser/myapp/aiservice-worker:latest
command: python -u worker.pyA minimal app with just one container:
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/myapp.git
GITLAB_BRANCH=main
COMPOSE_FILE=docker-compose.yml
COMPOSE_FILE_REGISTRY=docker-compose.image.yml
ENV_FILE=.env
GITLAB_REGISTRY_USER=youruser
[images]
app = Dockerfile : .
[production]
DROPLET_IP=123.45.67.89
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/myappSmall droplets (1-2 GB RAM) can't build Docker images — the build gets OOM-killed. Building locally on your Mac and pushing to the registry solves this completely:
| Approach | Build location | Droplet RAM needed | Speed |
|---|---|---|---|
operationsdo stack deploy |
On the droplet | 4+ GB | Slow |
operationsdo stack build-push + operationsdo stack deploy --registry |
On your Mac | 512 MB | Fast |
Build a subset of services:
operationsdo stack build-push --only frontend # just frontend
operationsdo stack build-push --only backend --only worker # backend + workerService names must match the keys in the [images] section.
operationsdo stack build-push reads each Dockerfile for ARG declarations and automatically passes matching values from your config as --build-arg. No manual --build-arg flags needed.
For example, if frontend/Dockerfile.prod contains:
ARG NEXT_PUBLIC_API_URL
ARG NEXTAUTH_SECRETAnd your [production] section has those keys, they are passed automatically:
docker build --build-arg NEXT_PUBLIC_API_URL=https://api.example.com \
--build-arg NEXTAUTH_SECRET=abc123 ...
GitLab's shared runners are metered. On a free namespace the minutes run out and
every job fails at once with ci_quota_exceeded — lint, test, build and
deploy — which reads like a broken pipeline rather than a bill. The droplet you
already deploy to has no quota, already runs Docker, and is already logged into
the registry.
[runner]
name = myapp-droplet
executor = docker
image = docker:latest ; the runner's own default job image
privileged = true ; REQUIRED if the pipeline uses docker:dind
run_untagged = true ; untagged = accepts the same jobs shared runners did
concurrent = 2 ; builds share the box with productionThe section is optional — the built-in defaults stand a runner up on their own.
operationsdo -c <rc> -t production gitlab runner setup # install + register + use local
operationsdo -c <rc> -t production gitlab runner status # which side takes jobs, and why
operationsdo -c <rc> gitlab runner logs --since 2h # jobs from the RUNNER'S OWN LOG (works while GitLab 429s)
operationsdo health [rc|droplet] [--offline] [--strict] # is this repo's setup sound, per subject (bare `health` = every subject)
# rc: every rc complete, and operations.do agrees (client, parent, binding, webhook)
# droplet: ssh, containers, disk, DNS → its IP, https; "no droplet (app-platform)" when it deploys elsewhere
# kept: devops/operationsdo/health/<subject>/<UTC>.json (operationsdo.health v2) + .md, and a revision per client
operationsdo gitlab runner now --watch 10 # what runs NOW: job, phase, `$ command`, elapsed, ETA
operationsdo gitlab runner jobs --name build:backend # every recorded job (runners + GitLab webhooks), paged
operationsdo gitlab runner stats --days 30 # per job: runs, failures, median, p90, trend
operationsdo gitlab runner job 18347257565 [--source gitlab] # one job's lines: runner box (default) or GitLab's trace
operationsdo gitlab pipelines eta 3112037764 --watch 15 # what is left of a pipeline, from typical durations
operationsdo gitlab pipelines history [--project P] [ID] # recorded pipelines per project; one pipeline's stages and where it failed
operationsdo gitlab pipelines graph --project P [--watch 10] # the repo's CI graph with the running/newest pipeline on it
operationsdo -c <rc> gitlab webhook install # GitLab pushes job/pipeline events (history, pipeline ETA)
operationsdo -c <rc> -t production gitlab runner use cloud # hand it back to GitLab
operationsdo -c <rc> -t production gitlab runner use localSwitching flips one project setting (shared_runners_enabled) and pauses or
resumes the droplet runner to match, so exactly one side accepts jobs — no
.gitlab-ci.yml edit and no job tags. The side being switched on goes first,
so there is never a window where nothing can accept a job.
If the pipeline uses image: docker:latest with a docker:dind service, pin
both to a matching major first:
image: docker:27
services:
- docker:27-dinddocker:latest is now Docker 29, whose default containerd image store pushes
OCI manifests that GitLab's registry rejects mid-push:
error from registry: blob unknown to registry - sha256:...
The image builds fine and most layers upload, then the push dies — every image,
reproducibly. GitLab's shared runners hide this by serving an older cached
latest, so it only appears once a self-hosted runner pulls the newest.
register creates the runner as runner_type=project_type with a single entry
in projects and locked: true — no other repo in the namespace can use it,
by construction. A droplet paid for by one app should not quietly run another
app's pipelines, least of all while it serves that app's production. For several
repos on one box you would want a group runner instead (not advisable next
to production).
Registration goes through operations.do: operationsdo gitlab runner register calls
/gitlab/clients/<client>/runners with the rc's OPERATIONS_API_KEY, and
operations.do creates the runner with the connector token it holds (the modern
POST /user/runners flow — that token needs the create_runner and
manage_runner scopes), handing the runner's own token back once for the SSH
registration. The rc therefore carries no GITLAB_TOKEN and no GITLAB_REPO_URL
for this: the project is the client's binding (operationsdo gitlab status).
Most commands need nothing but the .operationsdorc and SSH. Two groups —
operationsdo do apps and operationsdo do databases — reach resources that have no operations.do SDK endpoint
(App Platform, managed databases) and so call the DigitalOcean v2 API directly.
The .operationsdorc holds no DigitalOcean token; operations.do holds it. These two groups read,
on the operator's laptop:
DIGITALOCEAN_ACCESS_TOKENin the environment- whatever
doctlalready stored (doctl auth init)
Nothing a CI pipeline runs (deploy, verify, scan, registry-login, …) needs a DigitalOcean token.
Create a token at https://cloud.digitalocean.com/account/api/tokens. It needs
read scope for list / spec / env / firewall, and write scope for
release-domain / allow-droplet / deny-droplet.
All commands are run from the project directory that contains .operationsdorc.
Global options go before the command name:
operationsdo [--target TARGET] [--config PATH] [--dry-run] [--verbose] [--timing] [--preflight] COMMAND
| Option | Description |
|---|---|
--target, -t |
Config section / file suffix to use (default: production) |
--config, -c |
Explicit path to config file |
--dry-run |
Print commands without executing |
--verbose, -v |
Show extra output |
--timing |
Log per-phase durations to the console and a timing log in the current directory (path: OPERATIONSDO_TIMING_LOG) |
--preflight |
Run preflight checks before any command |
Full deployment pipeline — runs cleanup, sync, upload-env, (optional registry login), and restart in sequence over a single SSH connection.
operationsdo stack deploy # Build from source on droplet
operationsdo stack deploy --registry # Pull pre-built images from registry
operationsdo --target staging stack deploy # Deploy to staging
operationsdo --dry-run stack deploy # Preview all commandsPipeline steps:
- Cleanup — stop/remove containers, images, prune (preserves Caddy SSL volumes)
- Sync — git clone or fetch+reset on the droplet
- Upload env — SFTP the flattened config as the env file
- Registry login (if
--registry) —docker loginon the droplet - Restart —
docker compose up -d(with--buildor registry pull)
Build amd64 Docker images locally and push to GitLab Container Registry. Services are read from the [images] section in .operationsdorc.
operationsdo stack build-push # build all services
operationsdo stack build-push --only frontend # build one service
operationsdo stack build-push --only backend --only worker # build a subset
operationsdo --dry-run stack build-push # preview build commandsoperationsdo stack deploy runs docker compose down then up. That is a guaranteed outage
for as long as images pull and boot, and if the new build is broken the site
stays broken until a human notices.
operationsdo stack deploy --registry --rollout changes three things:
- No
down. Neither cleanup nor sync tear the stack down, so compose recreates only the containers whose image or config actually changed. - The release is gated on health.
docker compose up --waitblocks until every service with a healthcheck is healthy and exits non-zero otherwise; thenHEALTHCHECK_URLSare checked over the public internet. - A failed release rolls itself back. The last release that passed both
gates is recorded in a marker file in
DEPLOY_PATHon the droplet; on failure the previous tag is redeployed and re-verified — and the command still exits non-zero, so CI sees a failed release.
Two operational safeguards ship with --rollout (both tunable in the rc):
- The
compose upis bounded bytimeout.--wait-timeoutonly bounds the health wait, not the image pull —--pull alwaysdoes a per-image registry manifest check with no timeout of its own, so a throttled registry or a full disk (can't write new layers) wedges theupforever and the deploy never returns. The remotedocker compose upis wrapped intimeoutso that becomes a bounded non-zero exit (124) the rollout acts on. Budget =--wait-timeout+ 900 s of pull headroom; override withCOMPOSE_UP_TIMEOUT_SECONDS. - Disk is reclaimed after a healthy release. Every registry deploy pulls
fresh ~GB images and orphans the previous versions; over many deploys
/creeps to 100% and the nextcompose uphangs onno space left on device(the #1 cause of a wedged deploy). Once a release is proven healthy and recorded as last-known-good,operationsdorunsdocker image prune -a -f --filter until=${IMAGE_PRUNE_UNTIL:-72h}+docker volume prune -f— theuntilkeeps recent tags so a rollback still has something to restore. It runs on the success path only (never mid-rollback) and inside the deploy, not as a host cron (a host crontab entry tripsoperationsdo droplet scan's tampering tripwire). SetDISABLE_IMAGE_PRUNE=1to skip. Best-effort: a prune failure is a warning, never a failed deploy.
operationsdo -c $RC -t production stack deploy --registry --rollout --tag "$CI_COMMIT_SHA"
operationsdo -c $RC -t production stack release # what is deployed / what would restore
operationsdo -c $RC -t production stack rollback # restore last known-good
operationsdo -c $RC -t production stack rollback --to 1a2b3c4Automatic recovery, not zero-downtime. Compose replaces a container in
place, so during a failed rollout the service is down from when the bad
container starts until the rollback completes — bounded by --wait-timeout
instead of by how long it takes someone to notice. A successful rollout is a
single container restart per changed service.
True zero-downtime needs two upstreams behind the reverse proxy. With Caddy:
reverse_proxy backend-blue:5000 backend-green:5000 {
health_uri /api/v1/health
health_interval 5s
}
Caddy drops unhealthy upstreams automatically; start green, wait healthy, stop blue. That is a bigger change and needs enough RAM to run two copies briefly.
| Why | |
|---|---|
| Compose v2.1.1+ on the droplet | --wait / --wait-timeout. Check with docker compose version. |
| Healthchecks on the services that matter | --wait can only gate on services that declare one. A service without one counts as ready the moment it starts — it gates nothing. |
Compose images tagged :${IMAGE_TAG:-latest} |
So a release can be pinned and an older one restored. The :-latest default keeps every non-rollout path working unchanged. |
CI pushing SHA tags, not just :latest |
:latest is a moving pointer; you cannot roll back to it. |
- Tag images in the compose file:
image: reg/app-backend:${IMAGE_TAG:-latest}. - Give every service that matters a healthcheck. A worker with none will sail through the gate even if it crash-loops.
- Confirm CI pushes
:$CI_COMMIT_SHAalongside:latest. - Switch the deploy job to
stack deploy --registry --rollout --tag "$CI_COMMIT_SHA". - First run records the baseline; there is nothing to roll back to until one
release has passed, and
operationsdo stack deploy --rolloutsays so explicitly rather than pretending.
Restores the recorded known-good release, or an explicit tag. Health is verified before the restored tag is recorded, so rolling back to something broken cannot quietly become the fallback for next time.
Prints the recorded known-good tag and the image every running container is actually on — the fastest way to answer "what is live right now?".
Stop and remove all Docker containers, images, and volumes on the droplet. Caddy SSL certificate volumes (caddy_data, caddy_config) are preserved.
Clone the repository on the droplet if it doesn't exist, or fetch + hard reset to the configured branch.
Flatten the selected config section into a plain KEY=VALUE file and upload it via SFTP. Local-only keys (DROPLET_*, COMPOSE_FILE*, OPERATIONS_API_KEY, etc.) are excluded.
Provision an SSH deploy key for the droplet end to end, so deploys (locally and in CI) authenticate by key instead of password. Idempotent and guarded — it does not disable password auth.
operationsdo -c devops/operationsdo/app.operationsdorc -t production droplet setup-key
operationsdo ... droplet setup-key --dry-run # preview
operationsdo ... droplet setup-key --regenerate # overwrite the existing keySteps:
- Generate a 4096-bit RSA keypair at
--key-path(defaultdevops/operationsdo/keys/<rc-stem>-prod.pem) if it doesn't exist. - Append the public key to the droplet's
/root/.ssh/authorized_keys(over the current auth — password or an existing key). - Write
DROPLET_SSH_KEY_PATH+DROPLET_SSH_KEY_B64(base64 of the PEM — transferable into CI File variables) into the rc's target section. - Verify key-only login works.
Password auth stays ON as a fallback. Disable it afterwards, once key login is confirmed, with operationsdo droplet ssh-password off (or enable [[ssh]] in [security] and run operationsdo droplet harden ssh).
Run docker compose down then docker compose up -d. Includes --build unless --registry is passed.
Run docker compose up -d without stopping first.
Run docker login registry.gitlab.com on the droplet with a short-lived deploy token minted by operations.do (no GitLab token in the rc).
Show running containers, disk usage, and Docker disk usage on the droplet.
View latest docker compose logs on the droplet. Uses COMPOSE_FILE_REGISTRY when configured (production registry deploys).
operationsdo droplet logs # All services, last 100 lines
operationsdo droplet logs backend # Backend only
operationsdo droplet logs backend -n 200 # Last 200 lines
operationsdo droplet logs backend -f # Follow live
operationsdo droplet logs --since 30m # Logs from last 30 minutes
operationsdo droplet logs --list # Service status (docker compose ps)
operationsdo droplet logs --no-registry # Use COMPOSE_FILE instead of registry composeCheck if the droplet is reachable via SSH.
Verify Docker and Docker Compose are installed on the droplet.
Verify the droplet can reach the GitLab repository (git ls-remote against GITLAB_REPO_URL).
Inspect Caddy certificate directories on the droplet.
Search the droplet for .pem, .crt, and .key files.
Install Docker Engine, the compose plugin and buildx on a fresh droplet.
Distro-aware. Docker publishes a separate apt repository per distribution,
keyed by the distribution's codename — ubuntu/noble for Ubuntu 24.04,
debian/trixie for Debian 13. setup reads the droplet's own
/etc/os-release (not lsb_release, which a minimal Debian image does not
install) and derives the repository from it, then checks that Docker actually
publishes that suite before writing the source list — so a wrong codename
fails with the URL in the message instead of an opaque 404 from apt update
three steps later. Derivatives (Raspbian, Mint) fall back to the base named in
ID_LIKE.
Pin it when detection is not what you want:
[production]
DROPLET_OS = debian # debian | ubuntu
DROPLET_OS_CODENAME = trixie # only when the detected codename is unusableBoth are local-only keys: they describe the host, not the app, and are never uploaded to the droplet's env file.
docker-compose-plugin is installed by name. operationsdo speaks docker compose
(not the standalone docker-compose) in deploy, rollout, restart and status, and
the plugin only arrived as a Recommends of docker-ce — so an
--no-install-recommends policy used to break every deploy with nothing in
setup to explain it.
Open an interactive SSH session to the droplet.
Run preflight checks without executing any commands.
operationsdo droplet preflight # all checks
operationsdo droplet preflight --build # build-push checks only
operationsdo droplet preflight --deploy # deploy checks onlyChecks include:
- Config file exists and is parseable
- Compose file exists
- Dockerfiles exist (reads from
[images]section if available) - Docker running locally
- Registry credentials configured
- SSH connectivity to droplet
- Docker installed on droplet
- GitLab repository accessible
- API health endpoint
- DNS records on DigitalOcean match droplet IP (fetched via operations.do API)
- Public DNS propagation (warn-only if authoritative records are correct)
Preflight DNS flags:
operationsdo droplet preflight --configure-dns # create missing Caddy A records
operationsdo stack build-push --configure-dns # same during build
operationsdo droplet preflight --configure-dns --fix-wrong-dnsPush all .operationsdorc variables to GitLab CI/CD project variables. Creates a DOTENV_KEYS meta-variable listing which keys to include in .env reconstruction.
operationsdo gitlab ci-vars
operationsdo --dry-run gitlab ci-vars # preview without pushingDownload the project's CI/CD variables from GitLab and write a local .operationsdorc — for a new
machine with no rc yet. It needs a GitLab personal access token for that one call; the token is not
written into the rc.
operationsdo gitlab init --gitlab-token <your GitLab personal access token>operationsdo client mysuite # sub-apps with their monthly cost
operationsdo client mysuite costs --refresh # every resource with its cost (re-reads the account first)
operationsdo client mysuite subapps shop # App Platform apps + components, droplets, databases
operationsdo client mysuite subapps shop apps shop-prod components
operationsdo client mysuite subapps shop assign database olddb --cluster shared-pg # ownership only
operationsdo client mysuite unassigned # what no client owns (account-wide key)Which App Platform app a sub-app owns is registered in its rc — [app] app_platform = shop-prod (none for a
droplet app) — or assigned by hand. Costs are invoice-matched where the latest invoice names the resource, list
price otherwise; a database or Redis cluster shared by several sub-apps is split between them, so a suite's
total counts every dollar once. Nothing changes at DigitalOcean.
DNS goes through operations.do with the rc's own key — no DigitalOcean token, no doctl.
Which routes, from the rc:
| rc | routes | authorised by |
|---|---|---|
names its client (OPERATIONS_CLIENT_ID) — every app rc |
/sdk/dns/clients/<client>/… |
the key's grants client:<slug>:dns:<zone-or-name>:read|write |
| no client (an account key) | /sdk/dns/* |
the account-wide dns / dns:read / dns:write scope |
A key without the grant gets operations.do's own message, naming the scope it needs. Add it to the key the rc already has (nothing to rotate):
operationsdo do dns grant storybook.example.com --write --owner you@example.com # the rc's own key
operationsdo client key grant ci:example client:example:dns:example.com:read --owner you@example.com
operationsdo client key revoke-scope ci:example client:example:dns:example.com:read --owner you@example.comScope changes are owner-only — never by an API key. With --session <dashboard session token>
(or OPERATIONS_SESSION_TOKEN) they go to PATCH /sdk/api-keys/<key> on the rc's operations.do;
otherwise to a self-hosted operations.do running on your machine (--owner <email>).
operations.do validates each scope, accepts the client's id or slug and stores the slug, never
leaves a key with no scopes, and audits the change.
The zones this key may see (client rc: the granted zones and names; account key: every zone).
Create a zone. Account-wide — needs a dns:write key and no client in the rc.
List DNS records for a domain, including their record IDs.
The ID column is the point: operationsdo do dns delete-record takes --record-id, and
operationsdo do dns configure only reconciles the first A record per name and never
touches AAAA — so tidying a zone that App Platform used means deleting
specific records by id.
operationsdo do dns list-records --domain example.com
operationsdo do dns list-records --domain example.com --type Aoperationsdo do dns create-record --domain DOMAIN --type TYPE --name NAME --data DATA [--ttl TTL] [--priority N]
Create a DNS record.
operationsdo do dns create-record --domain example.com --type A --name @ --data 123.45.67.89
operationsdo do dns create-record --domain example.com --type CNAME --name www --data example.com.Fetch DNS records from operations.do and verify Caddy A records match DROPLET_IP (no changes).
Fetch DNS records, report missing/wrong A records, and create any that are missing for Caddy:
ROUTING_MODE=subdomain(default):A @andA api→DROPLET_IPROUTING_MODE=path:A @only
Reads ROOT_DOMAIN, DROPLET_IP, and ROUTING_MODE from .operationsdorc.
operationsdo do dns verify
operationsdo do dns configure # create missing records
operationsdo do dns configure --fix-wrong # also replace wrong IPsDelete a DNS record by ID.
Add a Google site verification TXT record. Checks for existing records and prompts to overwrite.
operationsdo do dns google-site-verification "google-site-verification=abc123"operationsdo do dns recreate-domain is the one DNS command that talks to DigitalOcean directly
(deleting a zone has no operations.do route), so it needs a DigitalOcean token (see
DigitalOcean API token).
operationsdo gitlab pages domain add storybook.example.com --dns # add → CNAME + TXT → verify → HTTPS
operationsdo gitlab pages domain add storybook.example.com # add, print the two records
operationsdo gitlab pages domain verify storybook.example.com # ask GitLab to check NOW
operationsdo gitlab pages domain list # verified until · certificate--dns creates the CNAME (<namespace>.gitlab.io.) and the TXT
(_gitlab-pages-verification-code.<domain> = gitlab-pages-verification-code=<code>) through the
rc's own key and its DNS grant (operationsdo do dns grant <domain> --write first), asks GitLab to
verify until the TXT is seen, then waits until https://<domain> serves a trusted certificate
(--timeout, default 900 s; Let's Encrypt can take up to an hour).
Verify matters: GitLab re-checks unverified domains only on its own schedule, and until then a
members-only site's sign-in fails on that domain (401 after signing in — the redirect carries an
empty root_namespace_id). The gitlab.io address works meanwhile.
DigitalOcean App Platform has no operations.do SDK endpoint, so these talk to the
DigitalOcean v2 API directly — which is all doctl ever did, minus the external
binary and its separate doctl auth init. See
DigitalOcean API token for auth.
List every app with its id, name, custom domains and default ingress. The domain column is the one doctl does not give you, and it is what you need when working out which app is holding a domain you want to move.
Download an app's spec — the doctl apps spec get replacement.
Always save this before editing an app. The spec is the only complete record
of a running App Platform deployment, so the file you write here is your rollback.
--format yaml needs PyYAML; JSON is the default and round-trips identically.
operationsdo do apps spec 1234-abcd -o spec.backup.jsonHarvest an app's environment variables — the first step of any migration off App
Platform, and the one worth doing carefully. The spec is the only complete record
of production config; a repo's own .env files are routinely missing things that
only ever existed there (SMTP credentials and third-party API keys especially).
operationsdo do apps env 1234-abcd --format rc >> devops/operationsdo/myapp.operationsdorc
operationsdo do apps env 1234-abcd --format table # shows which component set each var--format rcemits a block ready to paste into an.operationsdorc[production]section.- Duplicate keys are de-duplicated, first value kept, and a note is printed to
stderr if components disagree — inspect those with
--format table. - Values DigitalOcean stored as
type: SECRETcome back as an opaqueEV[1:...]blob. They are flagged, never emitted, and cannot be decrypted through the API — recover those from whoever issued them.
List the custom domains an app claims.
Find which app (if any) claims DOMAIN, and print the exact command to release
it. Use this when a DNS delete fails with "Record is managed by an App on this
account".
Detach a custom domain so DigitalOcean releases its DNS records.
While an app claims a domain, DigitalOcean manages that zone's records for it and refuses to delete them:
422 unprocessable_entity: Record is managed by an App on this account, and cannot be deleted
Removing the domain from the spec is the supported way out — DigitalOcean then
deletes the matching A/AAAA/CNAME records itself, after which the zone is yours
and operationsdo do dns configure can point the name at a droplet. The app keeps serving on
its default *.ondigitalocean.app ingress, so it stays usable as a rollback
target.
operationsdo do apps release-domain 1234-abcd --domain example.com --backup spec.backup.json
operationsdo --dry-run do apps release-domain 1234-abcd --domain example.com # preview onlyA managed database's trusted sources are the quietest way to break a migration. While an app runs on App Platform the app is the trusted source; move it to a droplet and, if the cluster has any firewall rules at all, the droplet is refused — with connection timeouts rather than an obvious permission error.
List managed database clusters.
Show a cluster's trusted sources.
An empty list is not a misconfiguration — it means no source restriction, so the cluster accepts connections from anywhere with the password, over TLS. A non-empty list means every client must be named explicitly, and a new droplet is refused until it is added.
Add a droplet to a cluster's trusted sources. Run it before pointing an app on that droplet at the database.
Accepts a droplet name as well as an id. The API replaces the whole rule set on write, so this reads the current rules, appends, and writes back — it never sends a bare list, which would silently revoke everything else's access. Adding the first rule to an unrestricted cluster switches it to allow-list mode, and the command warns before doing so.
operationsdo do databases firewall 95028fce-... # check first
operationsdo do databases allow-droplet 95028fce-... --droplet web-1Remove a droplet from the trusted sources (decommissioning).
How much of the cluster's connection limit is in use, per database, split active/idle.
Connection exhaustion is a cluster-wide failure that reads like an app-specific one — every
database on the cluster starts refusing with FATAL: remaining connection slots are reserved for roles with the SUPERUSER attribute, naming none of the apps responsible. So the number that
matters is not "is my app fine" but "how much of the shared limit is left". Warns past 90%.
Reads the same DBaaS Prometheus endpoint as operationsdo do databases metrics, so it needs no database
credentials. max_connections is not exposed by the API or the exporter, so it is derived from
the plan slug — DigitalOcean allots 25 connections per GB of RAM and reserves 3 for superusers
(verified: db-s-1vcpu-2gb -> 50, which is what SHOW max_connections returns).
pgcluster1 (a1b2c3d4-...) db-s-1vcpu-2gb
max_connections 50 (47 usable, 3 reserved for superusers)
used by databases 31 - 16 free
DATABASE TOTAL ACTIVE IDLE
appdb 19 1 18
otherdb 5 0 5
List the cluster's connection pools and total what they reserve.
operationsdo do databases pool-create CLUSTER --name N --db D --user U --size S [--mode transaction]
Put a PgBouncer pool in front of one database.
A pool multiplexes: in transaction mode a server connection is held only for the length of a
transaction, so a pool of 12 serves far more than 12 idle app connections. That is how you get a
20-container stack off 20 connections without buying a bigger cluster.
Two things to know before you run it:
- The pool reserves its size from the same cluster limit — it reallocates capacity, it does not add any.
- The URI it returns has a different port and the pool name in place of the database
name. Point the app at it, but keep migrations (alembic wants a real session for DDL) and
anything reading
pg_stat_activityon the direct URI — through a pooler that view shows the pooler's own connections, not your app's.
transaction mode forbids session state: LISTEN/NOTIFY, advisory locks, server-side cursors,
session SET, temp tables. Check the app before choosing it.
operationsdo do databases connections pgcluster1 # what is the damage
operationsdo do databases pool-create pgcluster1 --name appdb-pool \
--db appdb --user myapp --size 12
operationsdo do databases pools pgcluster1 # what is left for everyone elseAsk every running container on the droplet what database URI it is actually pointed at, and fail (exit 1) if any still connect directly.
Repointing an app at a pooler is an environment change, so it only takes effect on containers that were recreated. Restarting the two obvious services is not the same as restarting the stack: every cron and worker container keeps the old direct URI until it is recreated too.
Credentials are stripped on the droplet, before anything crosses the wire.
Delete a pool. Anything still pointed at its URI stops connecting immediately, so repoint the apps first.
A managed cluster's own daily snapshot lives inside the same DigitalOcean account as the database it protects. That covers a dropped table. It does not cover a lost account, a deleted cluster, or deciding to leave the provider — and the backup that saves you is one sitting on hardware you control, in a format you have actually restored at least once.
Dump a PostgreSQL database to the machine you run this on.
TARGET is a managed-cluster name or id (operationsdo do databases list); pass --uri instead for any other
PostgreSQL server. Credentials are resolved from the DigitalOcean API using the same token as
every other operationsdo do databases command, so there is nothing to paste and no password on the command line —
it travels in PGPASSWORD, never in argv.
operationsdo do databases backup pgcluster1 --db appdb # ./backups/pgcluster1/appdb/<ts>/
operationsdo do databases backup pgcluster1 --db appdb --verify # ...and prove it restores
operationsdo do databases backup --uri postgresql://u:p@localhost:5432/mydb
operationsdo do databases backup pgcluster1 --db appdb --keep 7 # prune older local runsThe source is only ever read from: pg_dump plus the read-only catalogue queries that build the
inventory. Options: --format custom|plain|both (default custom, restorable with pg_restore),
--schema (repeatable), --compress 0-9, --out DIR, --json.
A run directory holds the dump, and a manifest.json with sizes, sha256 checksums, timings,
versions, and a full inventory of the source — every table with its row estimate, plus views,
sequences and indexes. That inventory is what makes verification meaningful.
Two failure modes it refuses to walk into:
- A pooled connection.
pg_dumpcannot run through PgBouncer in transaction mode, and the failure reads like a network problem. Port 25061 or a-pooldatabase gets a warning naming the real cause. - A client older than the server.
pg_dumpwill not dump a server newer than itself. The version check happens before the dump, not 40 minutes into it.
Restore a backup run into a throwaway Postgres container and compare it against the manifest.
operationsdo do databases restore-check backups/pgcluster1/appdb/2026-09-05T14-28-20Z✓ restore verified — appdb.dump into postgres:16-alpine in 11.2s
tables 83/83 views 0/0 sequences 0/0 indexes 254/254
rows 2,852,533 restored (source estimated 2,760,997)
Every table, view, sequence and index in the manifest has to come back, and with --count-rows
(the default) a table that had rows in the source and is empty in the restore fails the check.
The container is destroyed afterwards (--keep-container to poke at the restored copy), the
source database is never contacted, and the exit code is non-zero when the check fails — so this
belongs in a cron or a CI job, not only in a terminal.
Restore diagnostics that say nothing about integrity are classified as benign rather than
reported as damage: dumping with a client newer than the server always produces a complaint about
a GUC that did not exist yet (transaction_timeout arrived in PostgreSQL 17), and a bare
container has never heard of the managed provider's roles.
List the backup runs on this machine — when, which database, how big, and whether the restore check passed.
Spaces is two APIs wearing one name. The keys are DigitalOcean's own v2 API,
authenticated with the same token as everything else here. The buckets are S3, spoken over
https://<region>.digitaloceanspaces.com and signed with a Spaces access key — a different
credential entirely. These commands do both halves so you do not have to think about which is
which.
Signing is done in-process rather than with boto3: every call here has an empty body, and adding a 30 MB AWS SDK to a CLI that gets pip-installed into each CI job to avoid forty lines of HMAC is a bad trade.
Create a bucket and an access key scoped to that bucket alone.
operationsdo do spaces create backups --region fra1The awkward part is that you need a key to make a bucket and a bucket to scope a key to. This resolves it by minting a full-access key, creating the bucket, minting the scoped key you keep, and deleting the full-access one — so the credential that could reach every bucket on the account exists for a few seconds and is never written down.
One readwrite key per bucket is what makes a leaked backup credential a contained problem: the
key lists its own bucket and gets AccessDenied on any other.
The secret is printed once. A Space bills at a flat monthly rate whether or not you use it.
List buckets. There is no DigitalOcean API for this — it is an S3 ListBuckets, so with no
SPACES_ACCESS_KEY/SPACES_SECRET_KEY in the rc a temporary key is minted and deleted around
the call.
Note it does not read STORAGE_ACCESS_KEY/STORAGE_SECRET_KEY. Those name an app's object
storage, which is often a local MinIO container with admin/password; handing
those to DigitalOcean gives InvalidAccessKeyId, which reads like a broken credential rather
than the wrong one.
List objects. Follows the continuation token, so it does not silently stop at 1000 keys.
How much a bucket holds, and where it went:
backups (fra1)
1 objects, 75.7 KB
BYTES OBJECTS PREFIX
75.7 KB 1 db-backups/backups
Spaces bills on stored bytes past the included allowance, and one total does not tell you anything actionable. A backup job whose retention quietly stopped working shows up here as one prefix that keeps growing.
Download one object. Streams to disk rather than into memory, writes a .part file and renames
on success — so an interrupted download never leaves something that looks like a complete dump.
operationsdo do spaces get backups db-backups/.../2026-09-05T16-50-36.sql.gz --out /tmp/restore.sql.gzoperationsdo do spaces copy SRC[/PREFIX] DST[/PREFIX] [--region fra1] [--acl private|public-read] [--dry-run] [--skip-existing|--overwrite] [--key K]… [--keys-from FILE] [--json]
Copy every object under a prefix into another bucket (or prefix), keeping each key relative to the
source prefix. operations.do does it with S3 CopyObject inside the region, so no bytes pass through
your machine, and it holds the DigitalOcean credential — this needs only OPERATIONS_API_KEY
(account-level, or scoped to the clients that own both buckets). OPERATIONS_API_URL /
OPERATIONS_API_KEY in the environment beat the rc; --api-url beats both. Existing objects are
skipped unless --overwrite; nothing is deleted from the source; a cross-region copy is refused.
--key (repeatable) or --keys-from FILE (relative keys, full keys or public URLs, one per line)
copies only the listed objects; one not under the source prefix is reported, not ignored.
operationsdo do spaces copy media/videos/ archive/2026/videos/ --acl public-read --dry-run
operationsdo do spaces copy media/videos/ archive/2026/videos/ --acl public-readoperationsdo do spaces cdn list / cdn ensure BUCKET --domain HOST [--region fra1] [--ttl 3600] [--wait 300] [--dry-run] [--json]
cdn ensure serves a bucket through DigitalOcean's CDN on your own hostname. operations.do (which
holds the DigitalOcean token) creates or reuses, in order: a Let's Encrypt certificate for the
hostname (its zone must be DNS-hosted by DigitalOcean — checked first), the CDN endpoint for
<bucket>.<region>.digitaloceanspaces.com with that hostname + certificate + ttl, and
CNAME <host> → <bucket>.<region>.cdn.digitaloceanspaces.com.. Run it twice and nothing changes.
Nothing else is touched: another record at the hostname, or the hostname on another bucket's
endpoint, is refused. A new certificate takes a minute or two; the command re-runs until it is
issued (up to --wait seconds, exit 1 if it is still pending). A client-scoped key needs
client:<slug>:write and client:<slug>:dns:<zone-or-name>:write. cdn list shows the account's
endpoints with each certificate's state (a client key sees its own buckets' only).
operationsdo do spaces cdn ensure myapp-assets --domain media.example.com --dry-run
operationsdo do spaces cdn ensure myapp-assets --domain media.example.com
operationsdo do spaces cdn listkeys shows every Spaces key and what it may reach (bucket:permission, or *ALL* for a
full-access one — worth grepping for).
key-rotate --bucket B replaces the key for one bucket. The new key is created and printed
first, then the old ones are revoked, so there is a moment where both work and none where
neither does. Anything still holding the old credential breaks the instant it is revoked, so for
a live consumer do it in two steps:
operationsdo do spaces key-rotate --bucket backups --keep-old # get the new one
# ... update the rc / CI variables / the app's storage endpoint ...
operationsdo do spaces key-rotate --bucket backups # then cut the old oneAn rc can say which CI/CD steps the project runs, instead of every tool guessing from empty keys
(DROPLET_IP= meant "no droplet yet" only to a human reading the comment):
[cicd]
test = on ; checks: ON unless switched off
security = on
build = off ; shipping steps: OFF unless switched on
deploy = off
scan_prod = off
runner = group:my-runner ; group:<name> | cloud | dropletEach step reaches CI as a plain GitLab variable CICD_<STEP>, which the job rules read
(- if: $CICD_DEPLOY != "on" → when: never), so the presence of <APP>_OPERATIONSDORC alone can
never switch a deploy on.
operationsdo -c $RC cicd status # each step: wanted, applied to GitLab or not, and what is LEFT (with commands)
operationsdo -c $RC cicd status --json # the same, as JSON
operationsdo -c $RC cicd status --check # exit 1 when anything is left
operationsdo -c $RC cicd apply # push CICD_<STEP> variables + runner routing (shared runners on/off)The section is optional: an rc without it is untouched by every command; cicd status only
suggests adding it (exit 0) and cicd apply refuses. A project on a group runner needs no
DROPLET_IP.
operationsdo do spaces above signs DigitalOcean calls with a DO token on this machine. These ask
operations.do instead — it holds the token and never returns it — so the app's own client-scoped
OPERATIONS_API_KEY (client:<slug>:write) is all the rc needs. operations.do only lets that key
touch buckets named after the client (<slug> or <slug>-…), never mints a full-access key for
it, and refuses another client's slug (403).
operationsdo app mysuite myapp spaces create myapp-assets \
--prefix users/ --prefix app/ --suffix CORE # bucket + ONE readwrite key, this bucket only
operationsdo app mysuite myapp spaces list
operationsdo app mysuite myapp spaces create myapp-assets --replace --suffix CORE # rotate
operationsdo app mysuite myapp spaces key-delete DO00…create writes SPACES_BUCKET|REGION|ENDPOINT|ACCESS_KEY|SECRET_KEY (+ _<SUFFIX>) into the rc
(--rc-section, default [DEFAULT]) and never prints the secret unless --show-secret. It also
reports the isolation probe: the new key's ListBuckets and a GET on other buckets (403 = denied;
any 200 revokes the key and fails). list warns about any leftover temporary full-access key.
--api-url targets another operations.do (e.g. a self-hosted one).
Basic health check against the operations.do API.
Detailed deployment status (database connection, Redis, version).
List all DigitalOcean droplets.
Get details for a specific droplet.
| Command | Does |
|---|---|
operationsdo gitlab runner setup |
install + register + use local, in one go |
operationsdo gitlab runner install |
put the gitlab-runner container on the droplet (idempotent) |
operationsdo gitlab runner register |
create the runner in GitLab, register the droplet against it |
operationsdo gitlab runner use cloud|local |
route the pipeline to GitLab or to the droplet |
operationsdo gitlab runner status |
which side takes jobs, and why |
operationsdo gitlab runner logs |
jobs each runner took, read from its own log over SSH (--via api: every machine operations.do manages); no GitLab API, so no rate limit |
operationsdo gitlab runner now |
what each runner machine runs now — job, phase (cloning / script / artifacts), the current $ command, elapsed vs typical, ETA; from operations.do's 10 s cache, no SSH and no GitLab |
operationsdo gitlab runner jobs / stats |
the CI job history operations.do records (runner logs + GitLab webhooks), keyset-paged; typical durations, p90, trend |
operationsdo gitlab runner job ID |
one job: its lines from the runner box (--source operationsdo, default) or GitLab's trace (--source gitlab, one API call) |
operationsdo gitlab pipelines history [ID] [--project P] [--backfill CLIENT] |
recorded pipelines: per project (runs, pass rate, typical duration), a project's timeline, one pipeline's stages/jobs and where it failed |
operationsdo gitlab pipelines eta ID |
a pipeline's remaining time from its jobs' typical durations |
operationsdo gitlab webhook install|status|remove |
the job + pipeline webhook on the bound project; GitLab pushes events instead of being polled |
operationsdo gitlab runner remove [--keep-container] |
unregister + drop the container |
An app that stores third-party credentials (OAuth tokens, connector keys, API keys) should encrypt them at rest, and a key that cannot be rotated is not really a key. These commands operate that keyring. They do NOT implement it: the app ships the engine and a registry of its encrypted columns, and these drive it.
Two things, and operationsdo crypto works there:
- the repo ships
scripts/crypto_keys.py, supportingaudit --jsonandrotate [--apply] --json(the engine lives inapp/services/crypto.py+crypto_audit.py+ a per-appencrypted_columns.pyregistry); - its rc declares where to run it, and which variable holds the ring:
CRYPTO_KEY_VAR = MYSUITE_ENCRYPTION_KEYS
CRYPTO_TARGETS = appone_backend:/code/scripts/crypto_keys.py
apptwo_backend:/app/scripts/crypto_keys.pyoperationsdo SSHes in and docker execs that script, so the database DSN and the key
never leave the droplet. A suite with two apps is two targets. Nothing needs an
HTTP endpoint or its own authentication.
MYSUITE_ENCRYPTION_KEYS=v2:<base64-32-bytes>,v1:<base64-32-bytes>
Newest first. Encryption uses the first key; decryption uses the version the
ciphertext names, because every value carries its own tag (v1$gAAAA…). That tag
is what makes a rotation resumable, measurable, and reversible.
One invariant, and the whole procedure follows from it:
The ring is always a SUPERSET of the key versions present in the data. Widen before writing. Narrow only once the census proves nothing is behind the key — forward and backward alike.
Hold it and the database is never unreadable, at any interruption point, in either direction.
| Command | Does | Writes? |
|---|---|---|
operationsdo crypto audit |
which key version every stored value is on, per app | no |
operationsdo crypto audit --verify |
the above, plus actually decrypts a sample per version | no |
operationsdo crypto rotate |
dry run — what a re-encryption would move | no |
operationsdo crypto rotate --apply |
re-encrypt everything onto the primary key | yes |
operationsdo crypto rotate-key |
the whole rotation: widen, deploy, re-encrypt, verify | yes |
operationsdo crypto rotate-key --resume / --rollback |
continue or unwind an interrupted rotation | yes |
operationsdo crypto retire-key <version> |
may this key be dropped? checks live rows AND backups | no |
audit exits non-zero when anything is unreadable, so it is safe in a script.
RC=devops/operationsdo/<app>.operationsdorc
operationsdo -c $RC -t production crypto audit --verify # baseline
operationsdo -c $RC -t production crypto rotate-key # the whole thing
operationsdo -c $RC -t production crypto audit --verify # confirmrotate-key prints the new key once — put it somewhere durable before
answering the prompt. Escrow before re-encryption is the one ordering that
cannot be recovered from if it is wrong: nothing in this system can read a value
whose key is gone.
It journals each step to a file in $DEPLOY_PATH on the droplet (never the key
itself — only a sha256 fingerprint; the previous ring is reconstructed by
removing the entry the run added, so a rotation begun on a laptop can be unwound
from anywhere). On failure it unwinds automatically, data first: values come
off the new key before the ring is allowed to narrow.
If the unwind itself cannot finish, it stops with both keys on the ring and says so. That is the safe place to stand, not a mess to tidy — a stalled rotation with both keys live is readable; a narrow ring with data behind the missing key is an incident.
--key-saved --yes makes it non-interactive, for a scheduled rotation.
rotate-key deliberately stops short of retiring. That step has no upside, is
never urgent, and coupling it would let an unattended run finish with an
unreadable database.
operationsdo -c $RC -t production crypto retire-key v1It refuses on either of two counts, and the second is the one that bites on a frequent rotation schedule:
- live data — the census still shows rows on that key, or it is the primary;
- backups — a retained dump still needs it.
operationsdo do databases backuprecords the key versions found in each dump, andoperationsdo do databases backupsshows them asNEEDS KEYS.
The live database moves onto the new key in minutes; last month's dump is frozen on whatever was primary when it was taken. A manifest that predates that record blocks retirement rather than being assumed safe — "we did not look" and "there is nothing there" must not be the same answer to "may I destroy this key".
It reports and refuses; it does not edit the rc. The dangerous step is cheap to perform and impossible to undo, so a human does it having read the answer.
A deploy can succeed while containers keep the OLD ring. The keyring is read
from the environment, so a container that was not recreated still holds the
previous one — and re-encrypting then is a silent no-op that reports success.
rotate-key gates on every target reporting the new key as primary before it
moves a single row.
Never reuse a version label with different key material. Issuing a fresh key
as v1 instead of v2 leaves a ring that looks complete while every existing
v1 value is permanently unreadable, and no census can see it — only
audit --verify, which actually decrypts. rotate-key refuses a label already on
the ring or present in the data.
operations.do holds the GitLab token as a connector (pasted once, checked against GitLab, encrypted at rest, never shown
again). A client is bound to a connector plus a project — sub-applications inherit
their parent's binding — and operationsdo gitlab drives that project with nothing but the
rc's own OPERATIONS_API_KEY (scoped client:<slug>:read|write).
# once, by the account owner (a key with gitlab:write, in OPERATIONS_GITLAB_API_KEY)
printf '%s\n' "$GITLAB_PAT" | operationsdo gitlab connectors add personal --token-stdin
operationsdo gitlab connectors projects personal --search myapp
operationsdo gitlab connectors project-create personal mygroup/myapp # find-or-create (private); re-run safe
operationsdo gitlab bind myapp --connector personal --project mygroup/myapp
operationsdo gitlab clients # every client and the binding that applies
# then, from any app repo — the client is the rc's OPERATIONS_CLIENT_ID
operationsdo gitlab status # binding + latest pipeline
operationsdo gitlab health [--json] # end-to-end access checklist (exit 1 on a hard failure)
operationsdo gitlab vars list [--reveal]
operationsdo gitlab vars get KEY [--scope production]
operationsdo gitlab vars set KEY VALUE [--masked] [--protected] [--raw] [--file] [--scope S]
operationsdo gitlab vars rm KEY [--scope S]
operationsdo --dry-run gitlab vars push # `operationsdo gitlab ci-vars`, without a GitLab token
operationsdo gitlab pipelines list [--ref main] [--status failed]
operationsdo gitlab pipelines show ID # with its jobs
operationsdo gitlab pipelines run [--ref R] [--var K=V ...] [--wait]
operationsdo gitlab pipelines wait|retry|cancel ID
operationsdo gitlab pipelines trace JOB_ID [--tail 200]
operationsdo gitlab pipelines retry-job|play JOB_ID
operationsdo gitlab mrs list [--state opened|merged|closed|all]
operationsdo gitlab mrs create SOURCE "title" [--target main] [--draft] [-d text]
operationsdo gitlab mrs show|close|reopen IID
operationsdo gitlab mrs update IID [--title T] [-d text]
operationsdo gitlab mrs merge IID [--squash] [--remove-source-branch]
operationsdo gitlab branches list|create NAME [--from ref]|rm NAME
operationsdo gitlab deploy-tokens list|mint droplet|build|check|revoke IDEvery command takes --client/-C <slug> (another client), --token, --api-url and
--json.
One read-only call (GET /api/v1/gitlab/clients/<client>/health) that walks the whole
chain a deploy depends on and prints a checklist, with the fix for anything that fails:
$ operationsdo -c devops/operationsdo/core.operationsdorc -t production gitlab health
gitlab health myapp → mygroup/myapp (connector personal, inherited from mysuite)
✓ binding inherited from mysuite → mygroup/myapp
✓ connector personal (https://gitlab.com)
✓ token valid — authenticates as owner
✓ token_expiry expires 2027-03-17 — 153 days left
✓ token_scopes operationsdo: …, api, …
✓ project mygroup/myapp (id 12345678, default branch main)
✓ access_level owner
✓ variables listable — 1 defined
✓ default_branch_protected main is protected
✓ runners shared runners off · group runners on · my-runner (group, online)
✓ job_token_allowlist mygroup/myapp is on the CLI project's allowlist
✓ latest_pipeline #2949757211 running on main https://gitlab.com/…/pipelines/2949757211
OK 12 passed · 0 failed · 0 warnings · 0 skipped
| mark | meaning |
|---|---|
✓ |
passed |
✗ |
a hard check failed — CI or operationsdo gitlab … will break; the command exits 1 |
! |
a warning (token expires in < 30 days, default branch unprotected, allowlist unreadable) or a failed latest pipeline — reported, does not change the exit code |
- |
skipped, because a check it depends on failed (no binding → nothing else can run) |
What each check proves: the client is bound (own binding or inherited from a parent —
it says which) and the connector exists; the connector token is accepted by GitLab
(GET /user), its expiry and scopes (api needed); the project is reachable and
the token's access level is Maintainer+ (variables, protected branches); CI/CD
variables are listable (counted, never shown); the default branch is protected;
runner routing — shared runners on, or an own/group runner online and unpaused; the
project is on the job-token allowlist of the project CI installs the CLI from (only when
CI installs it from a private GitLab package registry); and the latest pipeline on the default
branch (informational). No token value or variable value is ever returned. --json prints
the raw report ({ok, passed, failed, warnings, skipped, binding, checks: [{name, ok, severity, detail, fix, data?}]}) and keeps the exit code.
| Credential | Used by | Scope |
|---|---|---|
OPERATIONS_API_KEY |
vars, pipelines, mrs, branches, status, health | client:<slug>:read / :write (write also needed to read variable values) |
OPERATIONS_GITLAB_API_KEY |
connectors, bind, unbind, clients | gitlab:read / gitlab:write — account-wide: the owner's, never in an app rc |
Both are local-only: upload-env never ships them to a droplet.
No GitLab token in the rc. Commands reach GitLab through operations.do with the rc's own
OPERATIONS_API_KEY:
| command | how |
|---|---|
ci-vars, runner, protect-branch, schedule-security, mask-vars, rotate-env, upsert-var, compare-var |
the same GitLab API requests, sent through operations.do's proxy (allowlisted to the client's bound project, its runners and its ancestor groups) |
deploy / sync (droplet git clone/fetch), registry-login, deploy --registry |
a droplet deploy token: read_repository + read_registry, 90 days, rotated by every deploy |
build-push |
a build deploy token: write_registry, 1 day |
check-repo, preflight |
a check deploy token: read_repository, 1 day |
Deploy tokens are minted by operations.do from the connector — one project, only those
scopes, no API access — so the connector's personal token never leaves operations.do.
operationsdo gitlab deploy-tokens list|mint|revoke shows and manages them.
operationsdo gitlab init --gitlab-token (writing a brand-new rc from CI variables) is the one
command that takes a GitLab token, as an explicit argument.
Operate an app by its operations.do identity instead of an rc path. The ids live in the repo's rc, so the same words work for a human, CI and an LLM:
operationsdo app mysuite myapp logs core-frontend --prod --since 2h -g "email sent|smtp" -C 2
operationsdo app mysuite myapp logs core-backend --prod -f # attach (Ctrl-C detaches)
operationsdo app mysuite myapp logs core-worker --dev -n 50 # the local compose stack
operationsdo app mysuite myapp containers --prod
operationsdo app mysuite myapp health --prod # HEALTHCHECK_URLS of [production]
operationsdo app mysuite myapp health --dev --port 8087 # …of [development]
operationsdo app mysuite myapp evidence --prod --since 2h -q "why 500?" -o /tmp/ev.md
operationsdo app 22222222-… 11111111-… logs --prod # ids work tooResolution. CLIENT matches [app] parent / [app] parent_id; SUBAPP matches [app] slug /
[app] client / OPERATIONS_CLIENT_ID. Candidates are devops/operationsdo/*.operationsdorc and
./.operationsdorc under the current directory; --rc overrides. A wrong pair is refused with the
list of what the repo describes — it never guesses.
[DEFAULT]
OPERATIONS_CLIENT_ID=11111111-… ; the sub-app's id
[app]
slug = myapp
parent = mysuite
parent_id = 22222222-… ; the suite's id
[development] ; read by --dev; no secrets, mirrored in the .example
DEPLOYMENT = none
COMPOSE_FILE=docker-compose.dev-common.yml docker-compose.dev-core.yml
ENV_FILE=
HEALTHCHECK_URLS=http://mysuite.local/api/health,…Targets. --prod (default) reads [production] and runs over SSH. --dev reads
[development] and runs the same commands against the local compose stack in the repo root, and
may fall back to the tracked .example (a fresh clone has no real rc).
Secrets are masked on every path — magic-link tokens, URL credentials, passwords, provider keys
(sed on the droplet; the same patterns in Python for --dev). --raw disables it, loudly.
evidence writes a markdown pack — containers, the lines matching -g per container (with
context, timestamps) and an unfiltered tail of each — sized to hand to an LLM. On --dev it keeps
to this app's containers.
operationsdo droplet logs (rc-path form) has the same filters: --container, -g/--grep, -C, --since,
--until, -t, -f/--attach, --raw, --list.
--built-frontendruns the frontend's production image (next build+next start) instead ofnext dev— pages in ~0.1 s instead of 30–90 s;--down/--clean-builtremove what it built (label-scoped, named volumes untouched). Details: docs/specs/run-built-frontend.md.operationsdo run --staging-local -d --built-frontend operationsdo run --dev --built-frontend=web operationsdo run --clean-built [--all-projects]
One rc describes every environment as a section; run brings any of them up on this machine
with the repo's compose files. No .env files: the section's values are exported into the
docker compose process, where the compose files' ${VAR:-default} interpolation reads them.
operationsdo run # [development] (default)
operationsdo run --dev --logs # up detached, then follow logs (Ctrl-C leaves it running)
operationsdo run --dev --skip-rebuild # no teardown/build — just make sure it is up
operationsdo run --staging-local # [staging-local]: production values on *.local domains
operationsdo run --dev --print-env # what compose would see, secrets masked
operationsdo run --dev --down # tear down
operationsdo run --dev -- --no-deps core-backend # after `--`: straight to `compose up`
operationsdo run --dev --web:backend --scraper:backend:worker # only those services--dev = [development], --prod = [production], --stagging = --staging; any other
--<name> is [<name>]. Several rcs in devops/operationsdo/? --<rc stem> picks one
(--core → core.operationsdorc). The rc is found by walking up from the current directory; a
fresh clone with only the tracked .example can run any section that does not INHERIT.
What run does, in order: compose down + remove stale pinned containers → pick the Caddy port
(CADDY_HTTP_PORT, or CADDY_HTTP_FALLBACK_PORT when another stack holds it — exported as
LOCAL_PORT_SUFFIX) → check published host ports → add missing HOSTS to /etc/hosts (macOS
asks for your password in the system dialog) → start the shared devmail if the compose uses its
network → compose up --build.
| Key (in the section) | Meaning |
|---|---|
COMPOSE_FILE |
Space-separated compose files, relative to the repo root |
APP_DOMAIN |
The local domain; HOSTS defaults to APP_DOMAIN api.APP_DOMAIN |
HOSTS |
Explicit /etc/hosts names. Only .local/.test/.localhost/.internal are accepted — a real domain would shadow the live site |
INHERIT |
Start from another section's values (production). Its https://…{prod APP_DOMAIN} URLs are rewritten to http://…{APP_DOMAIN}{LOCAL_PORT_SUFFIX}, DROPLET_* are dropped, and AUTO_MIGRATE is forced to 0. <rc stem>:<section> (suite:production) inherits from another rc in the same folder: apps on one suite droplet keep their run sections in their own rc (operationsdo run --<app> --prod-local) and production values in the suite rc only |
CADDY_HTTP_PORT / CADDY_HTTP_FALLBACK_PORT |
Browser-facing port and its fallback (80 / 8081) |
DEVMAIL_COMPOSE |
Path to the shared devmail compose when it is not beside the repo (../devmail or ../*/devmail) |
${VAR} in a value |
Expanded against the section's env plus LOCAL_PORT_SUFFIX |
RUN_GROUP_<NAME> |
The services --<name> and --<name>:<part> select (below). Never exported to the containers |
[staging-local]
INHERIT=production
DEPLOYMENT=none
COMPOSE_FILE=docker-compose.dev-common.yml docker-compose.dev-core.yml
APP_DOMAIN=staging.myapp.local
CADDY_HTTP_FALLBACK_PORT=8081A suite runs several apps from one compose; usually you want one or two services, not all of them.
operationsdo run --staging-local --web # every service of the web group
operationsdo run --staging-local --web:backend # just its backend (+ what it depends on)
operationsdo run --staging-local --web:backend --scraper:backend:worker # several groups and parts
operationsdo run --staging-local --down --scraper:worker # stop + remove only that one- A group is
RUN_GROUP_<NAME>in the section: space-separated compose services, eachserviceorpart=service. Without one, the services named<group>or<group>-*form it, so a compose whose services are prefixed per app (scraper-backend,scraper-worker) needs no config. - A part is matched, in order: an alias (
part=), a service name,<group>-<part>, the one service ending-<part>. No match or several → the error lists the group's parts. - Nothing else is touched. No
compose downof the stack, ports checked for the selection only,--downremoves only the selection. Theirdepends_oncome up too (compose does that). - Profiles: a service behind a compose profile (opt-in workers, crons) can be selected by name.
- A bare
--<name>is an rc stem first, then a section, then a group;--<name>:<part>is always a selection.
[staging-local]
RUN_GROUP_WEB=backend frontend worker=backend-worker jobs=web-jobs-workerThe compose files decide what a section can change: anything hardcoded there (Redis, the queue, devmail) stays local whatever the rc says — which is how a production-data run is kept from sending real email or consuming the production queue.
| Key | Required by | Description |
|---|---|---|
DROPLET_IP |
All SSH commands | Server IP address |
DROPLET_USER |
All SSH commands | SSH username |
DROPLET_SSH_KEY_PATH / DROPLET_SSH_KEY_B64 |
All SSH commands | The droplet's SSH private key (a file, or base64 for CI) |
DROPLET_PASSWORD |
All SSH commands | SSH password — only a fallback; prefer a key and operationsdo droplet harden to turn passwords off |
DEPLOY_PATH |
deploy, sync, restart | Remote path for the project |
COMPOSE_FILE |
sync, restart, start, logs | Compose file for build-from-source mode |
COMPOSE_FILE_REGISTRY |
sync, restart, start (with --registry) |
Compose file for pre-built images |
CRYPTO_TARGETS |
crypto audit/rotate/retire-key |
Where to exec the keyring tools: container[:/path/to/scripts/crypto_keys.py], space- or comma-separated. Absent = not rotatable by operationsdo |
CRYPTO_KEY_VAR |
crypto rotate-key |
Which rc variable(s) hold the keyring, e.g. MYSUITE_ENCRYPTION_KEYS; a monorepo lists its per-app copies too, comma-separated (MYSUITE_ENCRYPTION_KEYS,MYSUITE_ENCRYPTION_KEYS_APPTWO,…): all are widened and narrowed together, the ring is read from the first, and copies that drifted apart are refused |
PUBLIC_PORTS |
verify ports |
Ports legitimately published to the world beyond 22/80/443 |
ENV_FILE |
upload-env, restart, start | Name of the env file on the droplet |
GITLAB_REPO_URL |
sync, deploy, build-push, check-repo | Git repository URL |
OPERATIONS_GITLAB_API_KEY |
operationsdo gitlab connectors/bind/unbind/clients |
An operations.do key with gitlab:read+gitlab:write (the account owner's; not for app rcs) |
GITLAB_BRANCH |
sync, deploy | Branch to deploy |
GITLAB_REGISTRY_USER |
build-push, registry-login | Registry username |
CADDY_DATA_VOLUME |
certs | Docker volume name for Caddy cert data |
ROOT_DOMAIN |
preflight (DNS check) | Root domain for DNS verification |
ROUTING_MODE |
preflight (DNS check) | subdomain (checks root + api.*) or path (checks root only) |
OPERATIONS_API_KEY |
client, gitlab, app, do dns, api |
The app's operations.do API key (scoped to its client) |
OPERATIONS_API_URL |
same | operations.do API URL (default https://api.operations.do) |
INHERIT / HOSTS / DEVMAIL_COMPOSE |
run |
Local-run plumbing: the section a run inherits, its /etc/hosts names, the devmail compose |
All other keys in the selected section are included in the uploaded env file. These are whatever your docker-compose.yml expects — the tool doesn't care what they are.
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/myapp.git
GITLAB_BRANCH=main
COMPOSE_FILE=docker-compose.yml
COMPOSE_FILE_REGISTRY=docker-compose.image.yml
ENV_FILE=.env
GITLAB_REGISTRY_USER=youruser
[images]
app = Dockerfile : .
[production]
DROPLET_IP=123.45.67.89
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/myapp
DATABASE_URL=postgres://user:pass@db:5432/mydb
SECRET_KEY=your-secretDeploy: operationsdo stack build-push && operationsdo stack deploy --registry
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/myapp.git
GITLAB_BRANCH=master
COMPOSE_FILE=docker-compose.ocean.yml
COMPOSE_FILE_REGISTRY=docker-compose.ocean-image.yml
ENV_FILE=.env.do
GITLAB_REGISTRY_USER=youruser
[images]
frontend = frontend/Dockerfile.prod : frontend
backend = backend/Dockerfile : backend
worker = backend/Dockerfile.worker : backend
[production]
DROPLET_IP=123.45.67.89
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/myapp
SQLALCHEMY_DATABASE_URI=postgresql://...
REDIS_URL=redis://redis:6379
NEXTAUTH_SECRET=your-secret
NEXT_PUBLIC_API_URL=https://api.example.comDeploy: operationsdo stack build-push && operationsdo stack deploy --registry (builds on your Mac, the droplet pulls)
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/bigapp.git
GITLAB_BRANCH=develop
COMPOSE_FILE=docker-compose.ocean.yml
COMPOSE_FILE_REGISTRY=docker-compose.ocean-image.yml
ENV_FILE=.env.ocean
GITLAB_REGISTRY_USER=youruser
ROUTING_MODE=path
[images]
frontend = frontend/Dockerfile : frontend
backend = backend/Dockerfile : .
backend-worker = backend/Dockerfile : .
aiservice = aiservice/Dockerfile : aiservice
aiservice-worker = aiservice/Dockerfile : aiservice
[production]
DROPLET_IP=203.0.113.10
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/bigapp
SQLALCHEMY_DATABASE_URI=postgresql://...
REDIS_URL=redis://redis:6379/2
OPENAI_API_KEY=sk-...
AI_SERVICE_URL=http://aiservice:8003
NEXT_PUBLIC_API_URL=https://bigapp.example.com/backend/api/v1Deploy: operationsdo stack build-push && operationsdo stack deploy --registry
[DEFAULT]
GITLAB_REPO_URL=https://gitlab.com/youruser/myapp.git
COMPOSE_FILE=docker-compose.ocean.yml
COMPOSE_FILE_REGISTRY=docker-compose.ocean-image.yml
ENV_FILE=.env.do
GITLAB_REGISTRY_USER=youruser
[images]
frontend = frontend/Dockerfile.prod : frontend
backend = backend/Dockerfile : backend
worker = backend/Dockerfile.worker : backend
[production]
GITLAB_BRANCH=master
DROPLET_IP=123.45.67.89
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/prod.pem # gitignored
DEPLOY_PATH=/opt/myapp
ENVIRONMENT=production
[staging]
GITLAB_BRANCH=develop
DROPLET_IP=123.45.67.90
DROPLET_USER=root
DROPLET_SSH_KEY_PATH=devops/operationsdo/keys/staging.pem # gitignored
DEPLOY_PATH=/opt/myapp-staging
ENVIRONMENT=stagingoperationsdo stack build-push && operationsdo stack deploy --registry # production
operationsdo --target staging stack build-push && operationsdo --target staging stack deploy --registry # stagingThe whole cutover, without doctl. Steps 1-2 are the ones people skip and
regret: the app spec is the only complete record of production config, and the
saved spec is the rollback.
# 1. Find the app(s) and harvest the REAL production env
operationsdo do apps list
operationsdo do apps env <app-id> --format rc >> devops/operationsdo/myapp.operationsdorc
operationsdo do apps spec <app-id> -o spec.backup.json # keep this
# 2. If the app uses a managed database, make sure the droplet may connect
operationsdo do databases list
operationsdo do databases firewall <cluster-id> # empty => unrestricted, nothing to do
operationsdo do databases allow-droplet <cluster-id> --droplet <droplet-name>
# 3. Stand the droplet up and deploy, while the old app still serves the domain
operationsdo droplet setup && operationsdo droplet harden
operationsdo stack deploy --registry
# 4. Verify against the droplet IP BEFORE touching DNS
curl -sI --resolve example.com:443:<droplet-ip> https://example.com/health -k
# 5. Cut DNS over. The domain must be released from the app first, or DO
# refuses to delete its records ("Record is managed by an App on this account").
operationsdo do apps find-domain example.com
operationsdo do apps release-domain <app-id> --domain example.com --backup spec.backup.json
operationsdo do dns list-records --domain example.com # check for stray A/AAAA
operationsdo do dns configure --fix-wrong
# 6. Prove it
operationsdo droplet verify ssh containers nonroot http security ports nextjsports is worth naming explicitly. security asks whether ufw is active, and it
can be active while a container publishes a database to the world: Docker inserts
its own iptables rules ahead of ufw's INPUT chain, so a 0.0.0.0 binding is
reachable whatever ufw status reports. ports lists what Docker actually binds
and fails on anything outside 22/80/443 (widen with PUBLIC_PORTS in the rc).
The old app keeps its default *.ondigitalocean.app ingress after step 5, so it
remains a working rollback target until you delete it.
operationsdo droplet setup # install Docker on fresh droplet
operationsdo stack deploy --registry # or: operationsdo stack deploy (build on droplet)operationsdo stack build-push # build on your Mac, push to the registry
operationsdo stack deploy --registry # the droplet pulls and restartsoperationsdo stack upload-env && operationsdo stack restart --registryoperationsdo droplet status # containers + disk
operationsdo droplet logs backend -n 200 # latest backend logs
operationsdo droplet logs backend -f # follow live
operationsdo droplet logs --since 1h # last hour
operationsdo droplet ssh # interactive shell