BPI Stack is a Python CLI tool for building, deploying, and managing software "stacks" — groups of containers defined in a component model similar to Docker Compose. It abstracts over Docker Compose and Kubernetes, allowing transparent deployment to either target.
Repository: https://github.com/bozemanpass/stack License: AGPL-3.0
- Language: Python 3.10+
- CLI framework: Click
- Entry point:
src/stack/main.py→cligroup - Package name:
stack(invoked asstackon the command line) - Version: defined in
pyproject.toml
# Install dependencies (creates .venv via uv)
./scripts/developer-mode-setup.sh
# Run the CLI in dev mode
uv run stack
# Build a distributable zipapp
./scripts/build_shiv_package.shuv run flake8 --config tox.iniFormatting uses black (available via uv run black). Linting config is in tox.ini.
Tests are bash shell scripts, not pytest. They require Docker and/or Kubernetes (Kind) to be available.
# Smoke tests (basic CLI functionality)
./tests/smoke-test/run-smoke-test.sh
# Docker deployment tests
./tests/deploy/run-deploy-test.sh
# Kubernetes deployment tests
./tests/k8s-deploy/run-k8s-deploy-test.shThe smoke tests require building a shiv package first (./scripts/build_shiv_package.sh).
src/stack/
├── main.py # CLI entry point (Click commands)
├── util.py # Shared utilities
├── log.py # Logging (colored, timestamped)
├── constants.py # Configuration constants
├── deploy/
│ ├── stack.py # Stack model (parsed from stack.yml)
│ ├── spec.py # Deployment specification (Spec, MergedSpec)
│ ├── deployer.py # Abstract Deployer base class
│ ├── deployer_factory.py # Factory: returns Docker or K8s deployer
│ ├── deployment.py # Deployment orchestration
│ ├── deployment_context.py # Tracks deployment directory/files
│ ├── compose/ # Docker Compose deployer implementation
│ │ └── deploy_docker.py
│ └── k8s/ # Kubernetes deployer implementation
│ ├── deploy_k8s.py
│ ├── helpers.py
│ └── cluster_info.py
├── build/ # Container building and publishing
├── repos/ # Git repository management
├── config/ # Profile-based configuration
├── init/ # Stack specification generation
├── chart/ # Mermaid diagram generation
├── webapp/ # Web application framework
└── data/ # Embedded templates, K8s components
- Stack (
deploy/stack.py): Parsed fromstack.ymlfiles. Defines containers, pods, and their relationships. Supports "super stacks" (composition of stacks). - Spec (
deploy/spec.py): Deployment specification — references a stack plus deployment config (target, volumes, resources, HTTP proxy).MergedSpeccombines multiple specs. - Deployer (
deploy/deployer.py): Abstract base withup(),down(),ps(),logs(),execute(), etc. Two implementations:DockerDeployer— generates Docker Compose YAML, usespython-on-whalesK8sDeployer— uses thekubernetesPython client, supports Kind for local clusters
- DeployerFactory (
deploy/deployer_factory.py): Returns the correct deployer based ondeploy-tofield in the spec (compose,k8s,k8s-kind).
Core commands defined in main.py:
deploy— create a deployment from a spec filemanage— manage a running deployment (start, stop, logs, exec, status)build containers— build container imagesfetch— clone/fetch git repositoriesinit— generate a spec fileprepare— build/download containerslist— list available stacksconfig— manage configuration profilesversion/update/webapp/chart
Stacks can also provide custom subcommands loaded dynamically.
click— CLI frameworkpython-on-whales(pinned 0.63.0) — Docker clientkubernetes— K8s API clientGitPython— git operationsPyYAML/ruamel.yaml.string— YAML parsinghumanfriendly— human-readable resource sizes
- Build backend:
uv_build - CI runs on GitHub Actions (see
.github/workflows/) - Workflows:
lint.yml,test.yml,test-deploy.yml,test-deploy-k8s.yml,test-database.yml,test-webapp.yml,publish.yml