@stupidhorse/cmps
v1.0.1
Published
Docker Compose launcher for Docker AI Sandboxes (SBX)
Maintainers
Readme
cmps
A CLI tool that launches Docker Compose files inside Docker AI Sandboxes (SBX), automatically publishing the right ports so services are reachable from your host.
Install
npm install -g @stupidhorse/cmpsOr run locally from the repo:
npm run build
node dist/index.jsor, link it
npm run build
npm linkCommands
cmps up [file]
Starts services defined in a Compose file, publishes their ports to the SBX sandbox, and prints a table of running services with clickable URLs.
file can be a local path or an OCI artifact reference:
cmps up # auto-detect compose file in current directory
cmps up ./path/to/compose.yml # explicit local file
cmps up oci://registry.example.com/app:1.0 # OCI artifactLocal file — what it does:
- Locates the compose file (
compose.yml,compose.yaml,docker-compose.yml, ordocker-compose.yaml) - Creates an SBX sandbox (
sbx run shell <dir>) with the compose directory mounted, if one isn't already running - Runs
docker compose up -dinside the sandbox — output streams directly to your terminal - Queries actual running ports with
docker compose ps - Publishes each port via
sbx ports <sandbox> --publish HOST:CONTAINER - Saves state to
~/.cmps/state.jsonsocmps downcan clean up correctly - Prints the service table
OCI artifact — what it does:
Same flow, except the compose file is pulled directly by Docker Compose from the registry. The current working directory is mounted as the sandbox workspace (making .env files and local assets available), and the sandbox name is derived from it.
# Runs the compose stack from an OCI artifact, mounting the current directory
cmps up oci://registry.example.com/myapp:latest
# With an explicit sandbox
cmps up oci://registry.example.com/myapp:latest --sandbox my-sandboxExample output:
▸ Sandbox: shell-myapp
▸ Compose file: oci://registry.example.com/myapp:latest
[+] Running 2/2
✔ Container myapp-web-1 Started
✔ Container myapp-api-1 Started
▸ Publishing ports...
✓ 8080:80
✓ 3000:3000
✓ Services running
Sandbox: shell-myapp
────────────────────────────────────────────────
SERVICE IMAGE PORT URL
────────────────────────────────────────────────
web nginx:latest 8080→80 http://localhost:8080
api node:18-alpine 3000→3000 http://localhost:3000
────────────────────────────────────────────────cmps down
Stops services and unpublishes all sandbox ports.
cmps down # uses sandbox recorded in state
cmps down --sandbox my-sandbox # explicit sandboxWhat it does:
- Queries
sbx ports <sandbox>for the live list of published ports and unpublishes them all - Runs
docker compose downinside the sandbox — output streams to your terminal - Clears the saved state
Sandbox lifecycle
When cmps up runs and no sandbox is found, it creates one automatically:
sbx run shell <workspace-dir>The sandbox name defaults to shell-<directory-name> (e.g. shell-myapp). For OCI references, the current working directory is used as the workspace.
To use a specific existing sandbox instead:
cmps up --sandbox my-sandbox
export SANDBOX_NAME=my-sandbox # or set permanentlySandbox name detection
cmps determines the sandbox name by checking these sources in order:
| Priority | Source |
| -------- | ----------------------------------------------------------------- |
| 1 | --sandbox <name> flag |
| 2 | SANDBOX_NAME environment variable |
| 3 | SBX_SANDBOX_NAME environment variable |
| 4 | SBX_NAME environment variable |
| 5 | Auto-detect via sbx ls (used if exactly one sandbox is running) |
| 6 | Derived from workspace directory: shell-<dirname> |
Compose file discovery
cmps up (with no file argument) searches the current directory in this order:
compose.ymlcompose.yamldocker-compose.ymldocker-compose.yaml
Development
npm install
npm run build # compile TypeScript → dist/
npm test # run Jest tests
npm run dev # run via ts-node (no build step)Requirements
- Node.js 18+
sbxCLI installed and in PATH- Docker with Compose plugin (
docker compose) available inside the sandbox
