Commands¶
Complete reference for the in-tree bp commands. Plugin commands have their own help text — see Plugins.
bp deploy¶
Generate deployment artifacts. Today's only sub-command is generate.
bp deploy generate <mode>¶
Render docker-compose.yml (and nginx/default.conf for nginx mode) for the chosen deployment shape.
Usage: bp deploy generate [OPTIONS] MODE
Arguments:
MODE {local|prod|nginx} [required]
Options:
-o, --output-dir DIRECTORY Where to write the compose file (default: repo root).
--api-port INTEGER Host port to publish the API on. [default: 8000]
--workers INTEGER Number of API workers (prod / nginx only). [default: 4]
--internal-subnet TEXT Subnet for the compose network, and the only peers uvicorn
takes forwarded headers from (nginx only).
[default: 172.31.240.0/24]
-f, --force Overwrite existing files without asking.
-y, --yes Assume yes for all prompts.
--dry-run Show what would be written, don't touch disk.
Modes¶
| Mode | Stack | Use for |
|---|---|---|
local |
API (target dev) + Postgres + Redis. Source mounted, hot-reload. |
Local development |
prod |
API (target prod, WORKERS env) + Postgres + Redis + a migrate one-shot. |
Single-host production, no proxy |
nginx |
prod + nginx reverse proxy on port 80. API exposed on internal network. |
Production behind a reverse proxy |
Every mode also gets a taskiq worker and a single scheduler, for a project that carries the
taskiq feature; a project without it gets neither.
All modes target the same multi-stage backend/Dockerfile — no per-mode Dockerfile is generated.
The migrate service sits behind a compose profile and nothing waits on it, so docker compose up
never migrates. Run it, then restart:
In that order a migration that fails leaves the old containers serving on the old schema, instead of restarting the API into a schema it can't use.
Examples¶
# Generate the dev stack at the repo root
uv run --no-sync bp deploy generate local
# Override workers and port
uv run --no-sync bp deploy generate prod --workers 8 --api-port 9000
# Dry run — print what would be written, don't touch disk
uv run --no-sync bp deploy generate nginx --output-dir /tmp/scratch --dry-run
# Generate into a separate directory (for staging configs in CI, etc.)
uv run --no-sync bp deploy generate prod --output-dir ./deploy/prod --yes
# Put the stack on another range when 172.31.240.0/24 clashes with a network you use
uv run --no-sync bp deploy generate nginx --internal-subnet 10.89.0.0/24
--internal-subnet has to name a network address of /8 or smaller for IPv4, /48 or smaller for IPv6: it is written both as the
compose network's ipam subnet and as FORWARDED_ALLOW_IPS for the API container, which decides
whose X-Forwarded-For and X-Forwarded-Proto the app believes. A value with host bits set
(172.31.240.1/24), a wildcard, or a wider range is refused before anything is written.
What it writes¶
| Mode | Files |
|---|---|
local |
<output-dir>/docker-compose.yml |
prod |
<output-dir>/docker-compose.yml |
nginx |
<output-dir>/docker-compose.yml<output-dir>/nginx/default.conf |
Existing files are protected: if a target already exists you'll be prompted to confirm overwrite. Use --force (or --yes) for non-interactive runs.
Generated compose conventions¶
All three modes use the same service names and networking:
api— the FastAPI applicationworker(taskiq feature) — Taskiq worker, runningtaskiq worker src.infrastructure.taskiq.worker:default_brokerscheduler(taskiq feature) — one Taskiq scheduler, runningtaskiq scheduler src.infrastructure.taskiq.scheduler:schedulerpostgres— Postgres 16 (alpine), with health checkredis— Redis 7 (alpine), with health checkmigrate(prod & nginx) — runsalembic upgrade headonce, withCONFIRM_PRODUCTION_MIGRATION=yes, behind themigrateprofile. Nothing depends on it: a deploy runs it and only then restarts the rest.nginx(nginx mode only) — Nginx 1.27 alpine, mounting the generatednginx/default.confread-only
The compose file references ./backend/.env for env vars. Make sure that file exists (cp backend/.env.example backend/.env) before docker compose up.
bp env¶
Inspect and prepare the runtime environment. Two sub-commands today.
bp env gen-secret¶
Generate a high-entropy hex secret suitable for SECRET_KEY.
Usage: bp env gen-secret [OPTIONS]
Options:
--bytes INTEGER RANGE [16 ≤ x ≤ 128] Number of random bytes (hex output is 2x). [default: 32]
$ uv run --no-sync bp env gen-secret
af97045f600bf988041ec4b6fd891763d8f79f01f0a0a4a7ed2022e57f771a9e
$ uv run --no-sync bp env gen-secret --bytes 16
c042a8aa0d678a9c73dc371e3e0d6a5e
The default produces 64 hex characters (256 bits of entropy) — enough for any of the boilerplate's secret slots (SECRET_KEY, signed-cookie secrets, etc.).
Run inside a project, the command checks each draw against the app's own secret-key rules and draws again while they would refuse it: about one hex key in 12.6 million runs through eight consecutive digits, which production refuses at startup. Run outside a project, where those rules aren't there to ask, it prints the first draw.
Pipe directly into your secrets manager:
bp env validate¶
Run the production security validator against your current settings, regardless of ENVIRONMENT.
$ uv run --no-sync bp env validate
Critical (2):
• SECRET_KEY is using default or insecure value. ...
• Database is using default credentials (POSTGRES_PASSWORD='postgres'). ...
The command:
- Imports the same
ProductionSecurityValidatorthe application uses at startup - Audits a copy of your settings whose
ENVIRONMENTreadsproduction, so the checks run whatever the configured environment is and a finding that names an environment names the one audited for - Captures critical errors and warnings, prints them grouped, and exits non-zero if any critical issues exist
Exit codes:
| Code | Meaning |
|---|---|
| 0 | No critical issues. Warnings (if any) are advisory. |
| 1 | One or more critical issues found. |
Useful in CI to gate deployments:
# .github/workflows/deploy.yml (excerpt)
- run: uv run --no-sync bp env validate
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
# ...
The validator's specific checks are documented in Production → The Production Validator.
Global Options¶
Typer-provided options work on any sub-command:
| Option | Effect |
|---|---|
--help |
Show command help and exit |
--install-completion |
Install shell completion (bash/zsh/fish) |
--show-completion |
Print completion script for the current shell |
Exit Codes¶
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Validation or operation failed |
| 2 | Argument parsing error (bad flag, missing argument) |
Discoverability¶
Every command has --help:
uv run --no-sync bp --help
uv run --no-sync bp deploy --help
uv run --no-sync bp deploy generate --help
uv run --no-sync bp env --help
uv run --no-sync bp env validate --help
The root bp --help lists every mounted command group, including those contributed by plugins. If a plugin you installed isn't showing up, see Plugins → Troubleshooting.