Commands
Overview
MiniPaaS CLI commands are organized into functional groups:
- deploy → build images, roll out the stack, release canaries, apply Caddy routing, and manage Swarm secrets and configs
- code → scaffold an environment, shape worker/job/cron services, and author Caddy routes
- shell → open a Docker-ready shell for local or remote contexts
All commands take the environment directory as their first positional argument: <env>, a directory that contains minipaas.yaml.
Common Flags
<env>: environment directory containingminipaas.yaml(first positional argument, all commands)--verbose: detailed output (all commands)
Command-specific flags:
--name <name>: object and mounted file name (deploy secret,deploy config); defaults to the positional file’s base name--for <value>: Compose service to attach the secret or config to (deploy secret,deploy config); repeatable--replicas <n>: replica count (deploy canary); defaults to1--cron <schedule>: cron schedule (code cron); defaults to* * * * *-c, --compose-file <file>: extra Compose file to register (code init); repeatable--local <bool>: use the local Docker daemon (code init); defaults totrue--host <user@host>: SSH target used when--local=false(code init)--registry <prefix>: image prefix for built images (code init), for exampleghcr.io/org--namespace <name>: deployment namespace for the stack, services, and networks (code init); defaults tominipaas
minipaas deploy: Build, rollout, canary, routing, secrets, configs
These commands load the environment’s Compose files listed in compose.files.
Build images
minipaas deploy build devRuns docker build for every service that declares a build section, tagging each image with its image value. When MINIPAAS_IMAGE_PREFIX is set, each built image is also pushed to that registry; authenticate first with docker login <registry-host>. When it is not set, images are built only and no push is performed. Images are built with host networking.
Roll out the stack
minipaas deploy rollout devRuns docker stack deploy --with-registry-auth against the environment’s Compose files using the environment’s namespace (default minipaas) as the stack name.
Release a canary
minipaas deploy canary dev --replicas 1 api workerRuns docker service update --with-registry-auth --replicas <n> --image <image> for each named service.
Apply routing
minipaas deploy routing devPosts the environment’s caddy.json to the minipaas_caddy container admin endpoint, reloading its configuration.
Create a secret
echo postgres | minipaas deploy secret dev \
--name postgres_password \
--for postgres --for api --for migrateCreates a content-addressed Swarm secret named <name>.<hash8> and patches the last Compose file that defines each service. That is the environment’s swarm override, so the project’s local-dev Compose file stays free of Swarm references.
Create a config
minipaas deploy config dev ./configs/app.json \
--name app.json \
--for api --for workerCreates a content-addressed Swarm config and patches the last Compose file that defines each service.
minipaas code: Compose helpers
Initialize an environment
minipaas code init minipaas --registry ghcr.io/orgcode init auto-detects the project’s local-dev Compose files in the project root (the parent of <env>): compose.yaml/compose.yml and compose.build.yaml/compose.build.yml. Pass -c to register additional Compose files. Pass --registry to push built images to an external registry; it is stored as MINIPAAS_IMAGE_PREFIX in minipaas.yaml. Omit it to build images without pushing them.
Pass --namespace to deploy under a different stack name. The namespace is used for the stack, every service (<namespace>_<service>), and the overlay networks (<namespace>_network, <namespace>_public). It defaults to minipaas and is recorded in minipaas.yaml.
Writes an environment directory containing:
minipaas.yamllisting the detected files, any-cfiles, and the generated base stack, in deep-merge ordercompose.apps.yamlbuilt from the source files, with services moved tominipaas_network, built images tagged${MINIPAAS_IMAGE_PREFIX}/<name>:${MINIPAAS_DEPLOY_VERSION}, and the monitoring labelsalert.cpu_thresholdandalert.memory_thresholdon each servicecompose.common.yml,compose.postgres.yml,compose.caddy.yml, andcaddy.json
The CLI loads all registered files in order and deep-merges them, so the local-dev file at the project root and the swarm overrides in the environment directory form one project.
Pass --local=false --host deploy@manager.example.com to target a remote Docker daemon over SSH. The CLI records docker.host: ssh://deploy@manager.example.com in minipaas.yaml.
Mark a service as a worker
minipaas code worker minipaas example-workerAdds a replicated deploy block (1 replica, start-first rolling update, restart on any failure) to each service in compose.apps.yaml.
Mark a service as a job
minipaas code job minipaas example-migrationAdds a one-shot deploy block (1 replica, stop-first, restart on failure up to 10 attempts) to each service in compose.apps.yaml.
Schedule a service as a cron job
minipaas code cron minipaas --cron "*/5 * * * *" example-cronAdds a swarm-cronjob deploy block (0 replicas plus swarm.cronjob.* labels) to each service in compose.apps.yaml. --cron defaults to * * * * *. The cluster must run swarm-cronjob; the Ansible role installs it on the host.
Route a service through Caddy
minipaas code route dev https://example.com/app api:8080Arguments:
- Public URL used to reach the service. Pass a plain path such as
/webto match every host: the host constraint is omitted. Hostless URLs use plain HTTP on port80, since TLS requires a domain; add a port to bind elsewhere, for examplehttp://:8000/web. service[:port]inside the environment’s stack; the port defaults to80.
Adds or replaces the matching host/path route in the environment’s caddy.json, pointing at minipaas_<service>. It also marks the service as resilient in compose.apps.yaml: a healthcheck against the target port plus a replicated deploy block (2 replicas, start-first rolling update, rollback on failure). Run minipaas deploy routing afterwards to apply the routing file.
minipaas shell: Docker-ready shell
Open a shell with DOCKER_HOST set from the environment:
minipaas shell devUseful for debugging or CI environments.
Notes
- Object names are content-addressed as
<name>.<hash8>; new content creates a new name. - All compose modifications are idempotent.
- Secrets/configs patch only the last compose file where each service appears.
- Secret/config and deploy commands expect the Docker engine to already be reachable.
- Deploy commands interpolate
varsfromminipaas.yaml, so${MINIPAAS_DEPLOY_VERSION}resolves during build, rollout, and canary. code routeupdatescaddy.jsonand the target service’s deploy block incompose.apps.yaml;deploy routingpushes the routing file to the running Caddy container.- The CLI never overwrites unrelated sections inside compose files.