diff --git a/README.md b/README.md index 762de1c..3387bf5 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ chmod +x ~/bin/stack ### Hard Mode Detailed documentation on the installation of stack and its prerequisites as well as how to update stack can be found [here](./docs/install.md). ## Learn More - - [Stack commands](./docs/cli.md) + - [Stack commands](./docs/commands.md) - [Recent New Features](./docs/recent-features.md) ## Contributing diff --git a/docs/cli.md b/docs/cli.md deleted file mode 100644 index 51e043a..0000000 --- a/docs/cli.md +++ /dev/null @@ -1,167 +0,0 @@ -# stack - -Sub-commands and flags - -## fetch stack repo -``` -$ stack fetch repo bozemanpass/example-todo-list -``` - -## list stacks - -``` -$ stack list -fixturenet-eth -siwe-express-example -siwe-on-fixturenet -todo -``` -Filter: -``` -$ stack list fixturenet -fixturenet-eth -siwe-on-fixturenet -``` - -Show paths and filter: -``` -$ stack list --show-path todo -todo /home/example/.config/stack/repos/github.com/bozemanpass/example-todo-list/stacks/todo -``` - -## prepare the stack containers - -Check if the containers are ready: - -``` -$ stack check --stack todo -bozemanpass/todo-frontend:stack needs to be built -bozemanpass/todo-backend:stack needs to be built - -Run 'stack prepare --stack todo' to prepare missing containers. -``` - -Download repos and build containers: -``` -$ stack prepare --stack todo -``` -Build a specific container: -``` -$ stack prepare --stack todo --include-containers "bozemanpass/todo-frontend" -``` -Force a full rebuild of container images: -``` -$ stack prepare --stack todo --build-policy build-force -``` - -Now check again: -``` -$ stack check --stack todo -bozemanpass/todo-frontend:d87d76671ad7dde247a328716c15827de9c1a89a ready -bozemanpass/todo-backend:d87d76671ad7dde247a328716c15827de9c1a89a ready - -All containers are ready to use. -``` - -See [fetching-containers](fetching-containers.md) for more information on fetching and building container images. - -## init - -Create a configuration spec file with the default values: -``` -$ stack init --stack todo --output todo.yml -``` - -Map stack ports to localhost: -``` -$ stack init --stack todo --output todo.yml --map-ports-to-host localhost-same -``` - -Set a configuration value: -``` -$ stack init --stack todo --output todo.yml \ - --map-ports-to-host localhost-same \ - --config REACT_APP_API_URL=http://127.0.0.1:5000/api/todos -``` - -Full Kubernetes configuration with image registry, HTTP ingress, and environment settings: -``` -$ stack init \ - --deploy-to k8s \ - --stack todo \ - --output todo.yml \ - --image-registry $IMAGE_REGISTRY \ - --kube-config /path/to/kubeconfig.yaml \ - --http-proxy-fqdn example-todo.bpi.servesthe.world \ - --config REACT_APP_API_URL=https://example-todo.bpi.servesthe.world/api/todos -``` - -## deploy - -Deploy the stack according to the configuration spec: - -``` -$ stack deploy --spec-file todo.yml --deployment-dir ~/deployments/todo -``` - -## manage - -Push image tags for stack containers (needed with Kubernetes and external image registries): -``` -$ stack manage --deployment-dir ~/deployments/todo push-images -``` - -Start the stack: -``` -$ stack manage --deployment-dir ~/deployments/todo start -``` - -Stop the stack: -``` -$ stack manage --deployment-dir ~/deployments/todo stop -``` - -Stop the stack and delete volumes: -``` -$ stack manage --deployment-dir ~/deployments/todo stop --delete-volumes -``` - -Reload to pick up config changes: -``` -$ stack manage --deployment-dir ~/deployments/todo reload -``` - -Show basic stack and container status: -``` -$ stack manage --deployment-dir ~/deployments/todo status -``` - -List running container ids, names, and ports: -``` -$ stack manage --deployment-dir ~/deployments/todo ps -``` - -Show port mapping details for a specific service and port: -``` -$ stack manage --deployment-dir ~/deployments/todo port frontend 3000 -``` - -Print service logs: -``` -$ stack manage --deployment-dir ~/deployments/todo logs -``` - -Follow logs (limited to _n_ lines): -``` -$ stack manage --deployment-dir ~/deployments/todo logs -f -n 10 -``` - -List service names: -``` -$ stack manage --dir ~/deployments/todo services -``` - -Execute a command in a running container: -``` -$ stack manage --dir ~/deployments/todo exec frontend 'node --version' -``` diff --git a/docs/commands.md b/docs/commands.md new file mode 100644 index 0000000..187c208 --- /dev/null +++ b/docs/commands.md @@ -0,0 +1,72 @@ +# Stack Commands + +Overview for all stack commands and subcommands. Please see the individual reference pages for documentation on each command, linked below. + +## Overview + +Stack uses a command/subcommand structure for organizing functionality. Commands are grouped by their primary function. + +## Global Options + +These options can be used with any command: + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--log-file` | TEXT | Log to file (default stdout/stderr) | - | +| `--debug` | FLAG | Enable debug options | From config | +| `--stack` | TEXT | Name or path of the stack | - | +| `--profile` | TEXT | Configuration profile to use | `config` | +| `--verbose` | FLAG | Log extra details | False | +| `--quiet` | FLAG | Suppress unnecessary log output | False | +| `-h`, `--help` | FLAG | Show help message | - | + +## Environment Variables + +| Variable | Description | +|----------|-------------| +| `STACK_CONFIG_PROFILE` | Default configuration profile | +| `STACK_REPO_BASE_DIR` | Base directory for repositories | +| `STACK_DEBUG` | Enable debug mode | +| `STACK_LOG_LEVEL` | Set log level | +| `STACK_USE_BUILTIN_STACK` | Use built-in stack definitions | + +## Configuration Files + +[Placeholder: Add information about configuration file locations and formats] + +## Getting Help + +For help with any command: +```bash +stack COMMAND --help +stack COMMAND SUBCOMMAND --help +``` + +## Command Categories + +### 📦 Repository & Build Management +- **[fetch](commands/fetch.md)** - Clone repositories and fetch resources +- **[prepare](commands/prepare.md)** - Build or download stack containers +- **[build](commands/build.md)** - Build stack components (containers, etc.) + +### ⚙️ Stack Configuration +- **[init](commands/init.md)** - Create a stack specification file +- **[config](commands/config.md)** - Manage configuration settings + +### 🚀 Deployment & Management +- **[deploy](commands/deploy.md)** - Deploy a stack +- **[manage](commands/manage.md)** - Manage a deployed stack (start, stop, etc.) + +### 📊 Information & Analysis +- **[list](commands/list.md)** - List available stacks +- **[check](commands/check.md)** - Check if stack containers are ready +- **[chart](commands/chart.md)** - Generate a mermaid graph of the stack + +### 🌐 Web Applications +- **[webapp](commands/webapp.md)** - Build, run, and deploy webapps + +### 🔧 Utility Commands +- **[version](commands/version.md)** - Print tool version +- **[update](commands/update.md)** - Update shiv binary from a distribution URL +- **[complete](commands/complete.md)** - Output shell completion script (hidden) + diff --git a/docs/commands/build.md b/docs/commands/build.md new file mode 100644 index 0000000..0c3d7c8 --- /dev/null +++ b/docs/commands/build.md @@ -0,0 +1,69 @@ +# stack build + +Build stack components (containers, etc.) + +## Synopsis + +```bash +stack build [OPTIONS] COMMAND [ARGS]... +``` + +## Description + +[Placeholder: Add detailed description of the build command and its purpose in building stack components] + +## Subcommands + +### containers + +Build stack containers + +```bash +stack build containers [OPTIONS] +``` + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--stack` | TEXT | Name or path of the stack | - | +| `--include` | TEXT | Only build these containers (can be used multiple times) | - | +| `--exclude` | TEXT | Don't build these containers (can be used multiple times) | - | +| `--git-ssh/--no-git-ssh` | FLAG | Use SSH for git rather than HTTPS | From config | +| `--build-policy` | CHOICE | Build policy to use | `as-needed` | +| `--extra-build-args` | TEXT | Supply extra arguments to build | - | +| `--dont-pull-images` | FLAG | Don't pull remote images | False | +| `--publish-images` | FLAG | Publish the built images | False | +| `--image-registry` | TEXT | Specify the remote image registry | From config | +| `--target-arch` | TEXT | Specify a target architecture (only for use with --dont-pull-images) | - | + +##### Build Policies + +Available build policies: +- `as-needed`: Build only if necessary +- `build`: Always build +- `build-force`: Force rebuild +- `prebuilt`: Use prebuilt images +- `prebuilt-local`: Use local prebuilt images +- `prebuilt-remote`: Use remote prebuilt images + +## Examples + +```bash +# Build all containers for a stack +stack build containers --stack my-stack + +# Build specific containers only +stack build containers --stack my-stack --include frontend --include backend + +# Force rebuild all containers +stack build containers --stack my-stack --build-policy build-force + +# Build and publish to registry +stack build containers --stack my-stack --publish-images --image-registry registry.example.com +``` + +## See Also + +- [stack prepare](prepare.md) - Build or download stack containers +- [stack deploy](deploy.md) - Deploy a stack diff --git a/docs/commands/chart.md b/docs/commands/chart.md new file mode 100644 index 0000000..5890c72 --- /dev/null +++ b/docs/commands/chart.md @@ -0,0 +1,47 @@ +# stack chart + +Generate a mermaid graph of the stack + +## Synopsis + +```bash +stack chart [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of how the chart command generates visual representations of stack architecture using Mermaid diagrams] + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--stack` | TEXT | Name or path of the stack | - | +| `--show-ports/--no-show-ports` | FLAG | Show port mappings in the chart | False | +| `--show-http-targets/--no-show-http-targets` | FLAG | Show HTTP proxy targets in the chart | True | +| `--show-volumes/--no-show-volumes` | FLAG | Show volume mounts in the chart | True | + +## Output Format + +The command generates a Mermaid diagram that can be rendered using: +- Mermaid CLI tools +- Markdown renderers with Mermaid support +- Online Mermaid editors + +## Examples + +```bash +# Generate a basic chart for a stack +stack chart --stack my-stack + +# Generate a chart showing all details +stack chart --stack my-stack --show-ports + +# Generate a minimal chart without volumes +stack chart --stack my-stack --no-show-volumes --no-show-http-targets +``` + +## See Also + +- [stack list](list.md) - List available stacks +- [stack check](check.md) - Check if stack containers are ready diff --git a/docs/commands/check.md b/docs/commands/check.md new file mode 100644 index 0000000..81ffbbf --- /dev/null +++ b/docs/commands/check.md @@ -0,0 +1,45 @@ +# stack check + +Check if stack containers are ready + +## Synopsis + +```bash +stack check [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of how the check command verifies container readiness and health status] + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--stack` | TEXT | Name or path of the stack | - | +| `--image-registry` | TEXT | Container image registry URL for this k8s cluster | From config | +| `--git-ssh/--no-git-ssh` | FLAG | Use SSH for git rather than HTTPS | From config | + +## Exit Codes + +- `0`: All containers are ready +- `1`: One or more containers are not ready +- `2`: Error occurred during check + +## Examples + +```bash +# Check if all containers in a stack are ready +stack check --stack my-stack + +# Check with specific registry +stack check --stack my-stack --image-registry registry.example.com + +# Check using git SSH +stack check --stack my-stack --git-ssh +``` + +## See Also + +- [stack manage status](manage.md#status) - Report stack and container status +- [stack list](list.md) - List available stacks diff --git a/docs/commands/complete.md b/docs/commands/complete.md new file mode 100644 index 0000000..5ebd81b --- /dev/null +++ b/docs/commands/complete.md @@ -0,0 +1,93 @@ +# stack complete + +Output shell completion script (Hidden Command) + +## Synopsis + +```bash +stack complete [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of shell completion functionality and how to enable it] + +This is a hidden command used to generate shell completion scripts for the stack tool. + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--shell` | TEXT | Name of shell to generate completions for | `bash` | + +## Supported Shells + +- `bash` - Bash shell completion +- `zsh` - Z shell completion +- `fish` - Fish shell completion +- [Placeholder: Add other supported shells] + +## Installation + +### Bash + +```bash +# Add to ~/.bashrc +eval "$(stack complete --shell bash)" + +# Or save to completion directory +stack complete --shell bash > /etc/bash_completion.d/stack +``` + +### Zsh + +```bash +# Add to ~/.zshrc +eval "$(stack complete --shell zsh)" + +# Or save to completion directory +stack complete --shell zsh > ~/.zsh/completions/_stack +``` + +### Fish + +```bash +# Save to fish completion directory +stack complete --shell fish > ~/.config/fish/completions/stack.fish +``` + +## Features + +- Command name completion +- Subcommand completion +- Option name completion +- File path completion for relevant options +- Stack name completion + +## Examples + +```bash +# Generate bash completion +stack complete --shell bash + +# Generate zsh completion +stack complete --shell zsh + +# Test completion (bash) +stack + +# Complete stack names +stack init --stack + +# Complete file paths +stack deploy --spec-file +``` + +## Troubleshooting + +[Placeholder: Add common completion issues and solutions] + +## See Also + +- Shell documentation for completion systems +- [stack config](config.md) - Manage configuration settings diff --git a/docs/commands/config.md b/docs/commands/config.md new file mode 100644 index 0000000..db4a256 --- /dev/null +++ b/docs/commands/config.md @@ -0,0 +1,109 @@ +# stack config + +Manage configuration settings for the stack command + +## Synopsis + +```bash +stack config [OPTIONS] COMMAND [ARGS]... +``` + +## Description + +[Placeholder: Add detailed description of configuration management, profiles, and persistent settings] + +## Subcommands + +### get + +Get the value of a configuration setting + +```bash +stack config get KEY +``` + +#### Arguments + +- `KEY` (required): The configuration key to retrieve + +### set + +Set the value of a configuration setting + +```bash +stack config set KEY [VALUE] +``` + +#### Arguments + +- `KEY` (required): The configuration key to set +- `VALUE` (optional): The value to set (if omitted, key is set to empty string) + +### unset + +Remove a configuration setting + +```bash +stack config unset KEY +``` + +#### Arguments + +- `KEY` (required): The configuration key to remove + +### show + +Show the full configuration + +```bash +stack config show +``` + +## Configuration Keys + +Common configuration keys include: + +| Key | Description | Default | +|-----|-------------|---------| +| `image-registry` | Default container image registry | - | +| `kube-config` | Path to Kubernetes config file | - | +| `git-ssh` | Use SSH for git operations | False | +| `deploy-to` | Default deployment target (compose/k8s) | `compose` | +| `http-proxy-fqdn` | Default HTTP proxy hostname for k8s | - | +| `debug` | Enable debug mode | False | + +## Profiles + +Configuration profiles can be selected using the `--profile` global option: + +```bash +stack --profile production config set image-registry prod.registry.com +``` + +## Examples + +```bash +# Set the default image registry +stack config set image-registry registry.example.com + +# Get a specific configuration value +stack config get image-registry + +# Show all configuration +stack config show + +# Remove a configuration setting +stack config unset git-ssh + +# Use a different profile +stack --profile dev config set deploy-to k8s +``` + +## Configuration File Location + +[Placeholder: Add information about where configuration files are stored] + +## See Also + +- [stack init](init.md) - Create a stack specification file +- [stack deploy](deploy.md) - Deploy a stack diff --git a/docs/commands/deploy.md b/docs/commands/deploy.md new file mode 100644 index 0000000..b740169 --- /dev/null +++ b/docs/commands/deploy.md @@ -0,0 +1,69 @@ +# stack deploy + +Deploy a stack + +## Synopsis + +```bash +stack deploy [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of the deployment process, including how it creates deployment artifacts from spec files] + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--cluster` | TEXT | Specify a non-default cluster name | - | +| `--spec-file` | TEXT | Spec file to use to create this deployment (required, can be used multiple times) | - | +| `--deployment-dir` | TEXT | Create deployment files in this directory | - | + +## Deployment Process + +1. Reads the specification file(s) +2. Creates deployment directory structure +3. Generates deployment artifacts (docker-compose.yml or k8s manifests) +4. Prepares configuration files +5. Sets up volumes and networking + +## Deployment Targets + +The deployment target is specified in the spec file and can be: +- `compose`: Docker Compose deployment +- `k8s`: Kubernetes deployment +- `k8s-kind`: Kubernetes in Docker (kind) deployment + +## Examples + +```bash +# Deploy using a single spec file +stack deploy --spec-file my-stack.yml --deployment-dir ~/deployments/my-stack + +# Deploy with multiple spec files +stack deploy --spec-file base.yml --spec-file overrides.yml --deployment-dir ~/deployments/my-stack + +# Deploy to a specific cluster +stack deploy --spec-file my-stack.yml --cluster staging --deployment-dir ~/deployments/staging +``` + +## Directory Structure + +The deployment directory will contain: +``` +deployment-dir/ +├── compose/ # For Docker Compose deployments +│ └── docker-compose.yml +├── k8s/ # For Kubernetes deployments +│ ├── manifests/ +│ └── configmaps/ +├── config/ # Configuration files +└── spec.yml # Copy of deployment spec +``` + +## See Also + +- [stack init](init.md) - Create a stack specification file +- [stack manage](manage.md) - Manage a deployed stack +- [stack prepare](prepare.md) - Build or download stack containers diff --git a/docs/commands/fetch.md b/docs/commands/fetch.md new file mode 100644 index 0000000..cd73b1e --- /dev/null +++ b/docs/commands/fetch.md @@ -0,0 +1,77 @@ +# stack fetch + +Clone repositories and fetch resources + +## Synopsis + +```bash +stack fetch [OPTIONS] COMMAND [ARGS]... +``` + +## Description + +[Placeholder: Add detailed description of how fetch retrieves repositories and other resources needed for stack deployment] + +## Subcommands + +### repo + +Clone a repository + +```bash +stack fetch repo REPO-LOCATOR [OPTIONS] +``` + +#### Arguments + +- `REPO-LOCATOR` (required): Repository identifier in format `owner/repo` or full URL + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--git-ssh/--no-git-ssh` | FLAG | Use SSH for git rather than HTTPS | From config | +| `--git-pull` | FLAG | Pull the latest changes for an existing repo | False | + +## Repository Locator Format + +The repository locator can be specified as: +- GitHub shorthand: `owner/repo` (e.g., `bozemanpass/example-todo-list`) +- Full HTTPS URL: `https://github.com/owner/repo.git` +- Full SSH URL: `git@github.com:owner/repo.git` + +## Repository Storage + +Repositories are cloned to: +- Default: `$STACK_REPO_BASE_DIR` (if set) +- Otherwise: `~/stack/repositories/` + +## Examples + +```bash +# Fetch a repository using GitHub shorthand +stack fetch repo bozemanpass/example-todo-list + +# Fetch using full HTTPS URL +stack fetch repo https://github.com/bozemanpass/example-todo-list.git + +# Fetch using SSH +stack fetch repo bozemanpass/example-todo-list --git-ssh + +# Update an existing repository +stack fetch repo bozemanpass/example-todo-list --git-pull + +# Fetch with SSH and pull latest +stack fetch repo bozemanpass/example-todo-list --git-ssh --git-pull +``` + +## Environment Variables + +| Variable | Description | +|----------|-------------| +| `STACK_REPO_BASE_DIR` | Base directory for cloned repositories | + +## See Also + +- [stack prepare](prepare.md) - Build or download stack containers +- [stack build](build.md) - Build stack components diff --git a/docs/commands/init.md b/docs/commands/init.md new file mode 100644 index 0000000..4e59aca --- /dev/null +++ b/docs/commands/init.md @@ -0,0 +1,107 @@ +# stack init + +Create a stack specification file + +## Synopsis + +```bash +stack init [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of how init generates deployment specifications from stack definitions] + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--stack` | TEXT | Name or path of the stack | - | +| `--git-ssh/--no-git-ssh` | FLAG | Use SSH for git rather than HTTPS | From config | +| `--config` | TEXT | Provide config variables for the deployment (can be used multiple times) | - | +| `--config-file` | TEXT | Provide config variables in a file for the deployment | - | +| `--cluster` | TEXT | Specify a non-default cluster name | - | +| `--deploy-to` | CHOICE | Cluster system to deploy to (`compose`, `k8s`, or `k8s-kind`) | From config or `compose` | +| `--kube-config` | TEXT | Provide a config file for a k8s deployment | From config | +| `--image-registry` | TEXT | Container image registry URL for this k8s cluster | From config | +| `--http-proxy-target` | TEXT | k8s http proxy settings in format: `target_svc:target_port[path]` (multiple) | - | +| `--http-proxy-fqdn` | TEXT | k8s http proxy hostname to use | From config | +| `--http-proxy-clusterissuer` | TEXT | k8s http proxy cluster issuer | From config or `letsencrypt-prod` | +| `--output` | TEXT | Write yaml spec file here (required) | - | +| `--map-ports-to-host` | CHOICE | Port mapping strategy | See below | + +## Port Mapping Strategies + +| Strategy | Description | Use Case | +|----------|-------------|----------| +| `any-variable-random` | Docker default - random ports on any interface | Development | +| `localhost-same` | Same ports on localhost only | Local development | +| `any-same` | Same ports on any interface | Production-like local | +| `localhost-fixed-random` | Fixed random ports on localhost | Consistent local dev | +| `any-fixed-random` | Fixed random ports on any interface | Consistent testing | +| `k8s-clusterip-same` | K8s default - ClusterIP with same ports | Kubernetes | + +## Configuration Variables + +Configuration variables can be provided in two ways: + +1. **Command line**: `--config KEY=VALUE` +2. **Config file**: `--config-file path/to/config.env` + +Config file format: +```env +DB_HOST=localhost +DB_PORT=5432 +API_KEY=secret123 +``` + +## Examples + +### Docker Compose Deployment + +```bash +# Basic compose deployment +stack init --stack my-stack --output my-stack.yml --deploy-to compose + +# With port mapping +stack init --stack my-stack --output my-stack.yml \ + --deploy-to compose --map-ports-to-host localhost-same + +# With configuration +stack init --stack my-stack --output my-stack.yml \ + --config DB_HOST=postgres --config API_PORT=8080 +``` + +### Kubernetes Deployment + +```bash +# Basic k8s deployment +stack init --stack my-stack --output my-stack.yml \ + --deploy-to k8s --image-registry registry.example.com + +# With HTTP proxy +stack init --stack my-stack --output my-stack.yml \ + --deploy-to k8s \ + --http-proxy-fqdn my-app.example.com \ + --http-proxy-target frontend:3000 + +# Kind (Kubernetes in Docker) +stack init --stack my-stack --output my-stack.yml \ + --deploy-to k8s-kind --cluster local-dev +``` + +## Output Format + +The generated specification file contains: +- Stack definition +- Deployment target configuration +- Container specifications +- Network and volume definitions +- Configuration variables +- Port mappings + +## See Also + +- [stack deploy](deploy.md) - Deploy a stack +- [stack config](config.md) - Manage configuration settings +- [stack prepare](prepare.md) - Build or download stack containers diff --git a/docs/commands/list.md b/docs/commands/list.md new file mode 100644 index 0000000..32fae20 --- /dev/null +++ b/docs/commands/list.md @@ -0,0 +1,71 @@ +# stack list + +List available stacks + +## Synopsis + +```bash +stack list [FILTER] [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of how list discovers and displays available stacks] + +## Arguments + +- `FILTER` (optional): Filter pattern to match stack names + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--show-path` | FLAG | Show stack path along with name | False | + +## Stack Discovery + +Stacks are discovered from: +1. Built-in stacks in the stack tool +2. Cloned repositories in `$STACK_REPO_BASE_DIR` +3. Custom stack paths specified with `--stack` + +## Output Format + +Default output: +``` +stack-name-1 +stack-name-2 +stack-name-3 +``` + +With `--show-path`: +``` +stack-name-1: /path/to/stack1 +stack-name-2: /path/to/stack2 +stack-name-3: /path/to/stack3 +``` + +## Examples + +```bash +# List all available stacks +stack list + +# List stacks with paths +stack list --show-path + +# Filter stacks by pattern +stack list webapp + +# Filter with wildcard pattern +stack list "test-*" + +# Show paths for filtered stacks +stack list database --show-path +``` + +## See Also + +- [stack check](check.md) - Check if stack containers are ready +- [stack chart](chart.md) - Generate a mermaid graph of the stack +- [stack init](init.md) - Create a stack specification file diff --git a/docs/commands/manage.md b/docs/commands/manage.md new file mode 100644 index 0000000..7d58057 --- /dev/null +++ b/docs/commands/manage.md @@ -0,0 +1,191 @@ +# stack manage + +Manage a deployed stack (start, stop, etc.) + +## Synopsis + +```bash +stack manage --dir DEPLOYMENT_DIR COMMAND [ARGS]... +``` + +## Description + +[Placeholder: Add detailed description of stack management operations and lifecycle] + +## Global Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--dir` | TEXT | Path to deployment directory (required) | - | + +## Subcommands + +### start + +Start the stack + +```bash +stack manage --dir DEPLOYMENT_DIR start [OPTIONS] [EXTRA_ARGS]... +``` + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--stay-attached/--detatch-terminal` | FLAG | Stay attached to see container output | False | +| `--skip-cluster-management/--perform-cluster-management` | FLAG | Skip cluster initialization/tear-down (kind-k8s only) | False | + +#### Arguments + +- `EXTRA_ARGS`: Additional arguments passed to the underlying deployment tool + +### stop + +Stop the stack and remove the containers + +```bash +stack manage --dir DEPLOYMENT_DIR stop [OPTIONS] [EXTRA_ARGS]... +``` + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--delete-volumes/--preserve-volumes` | FLAG | Delete data volumes | False | +| `--skip-cluster-management/--perform-cluster-management` | FLAG | Skip cluster initialization/tear-down (kind-k8s only) | False | + +### ps + +List running containers in the stack + +```bash +stack manage --dir DEPLOYMENT_DIR ps +``` + +### status + +Report stack and container status + +```bash +stack manage --dir DEPLOYMENT_DIR status +``` + +### logs + +Get logs for running containers + +```bash +stack manage --dir DEPLOYMENT_DIR logs [OPTIONS] [EXTRA_ARGS]... +``` + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--tail`, `-n` | INTEGER | Number of lines to display | All | +| `--follow`, `-f` | FLAG | Follow log output | False | + +### exec + +Execute a command inside a container + +```bash +stack manage --dir DEPLOYMENT_DIR exec [EXTRA_ARGS]... +``` + +#### Arguments + +- `EXTRA_ARGS`: Container name and command to execute + +### port + +List mapped ports + +```bash +stack manage --dir DEPLOYMENT_DIR port [EXTRA_ARGS]... +``` + +### push-images + +Push container images/tags to the image registry + +```bash +stack manage --dir DEPLOYMENT_DIR push-images +``` + +### reload + +Reload the stack to pick up config changes + +```bash +stack manage --dir DEPLOYMENT_DIR reload +``` + +### services + +List stack service names + +```bash +stack manage --dir DEPLOYMENT_DIR services +``` + +## Examples + +### Starting and Stopping + +```bash +# Start a stack +stack manage --dir ~/deployments/my-stack start + +# Start and stay attached to see output +stack manage --dir ~/deployments/my-stack start --stay-attached + +# Stop a stack (preserve volumes) +stack manage --dir ~/deployments/my-stack stop + +# Stop and delete volumes +stack manage --dir ~/deployments/my-stack stop --delete-volumes +``` + +### Monitoring and Debugging + +```bash +# Check status +stack manage --dir ~/deployments/my-stack status + +# View logs +stack manage --dir ~/deployments/my-stack logs + +# Follow logs for specific service +stack manage --dir ~/deployments/my-stack logs -f frontend + +# Tail last 100 lines +stack manage --dir ~/deployments/my-stack logs -n 100 + +# List running containers +stack manage --dir ~/deployments/my-stack ps + +# List services +stack manage --dir ~/deployments/my-stack services +``` + +### Container Operations + +```bash +# Execute command in container +stack manage --dir ~/deployments/my-stack exec backend bash + +# Check port mappings +stack manage --dir ~/deployments/my-stack port + +# Push images to registry +stack manage --dir ~/deployments/my-stack push-images + +# Reload configuration +stack manage --dir ~/deployments/my-stack reload +``` + +## See Also + +- [stack deploy](deploy.md) - Deploy a stack +- [stack init](init.md) - Create a stack specification file diff --git a/docs/commands/prepare.md b/docs/commands/prepare.md new file mode 100644 index 0000000..5510704 --- /dev/null +++ b/docs/commands/prepare.md @@ -0,0 +1,112 @@ +# stack prepare + +Build or download stack containers + +## Synopsis + +```bash +stack prepare [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of how prepare orchestrates the building and downloading of containers needed for a stack] + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--stack` | TEXT | Name or path of the stack | - | +| `--include-containers` | TEXT | Only build/download these containers (multiple) | - | +| `--exclude-containers` | TEXT | Don't build/download these containers (multiple) | - | +| `--include-repos` | TEXT | Only clone these repositories (multiple) | - | +| `--exclude-repos` | TEXT | Don't clone these repositories (multiple) | - | +| `--git-ssh/--no-git-ssh` | FLAG | Use SSH for git rather than HTTPS | From config | +| `--git-pull` | FLAG | Pull the latest changes for an existing repo | False | +| `--build-policy` | CHOICE | Build policy to use | `as-needed` | +| `--extra-build-args` | TEXT | Supply extra arguments to build | - | +| `--dont-pull-images` | FLAG | Don't pull remote images | False | +| `--publish-images` | FLAG | Publish the built images | False | +| `--image-registry` | TEXT | Specify the remote image registry | From config | +| `--target-arch` | TEXT | Specify a target architecture (with --dont-pull-images) | - | + +## Build Policies + +| Policy | Description | Use Case | +|--------|-------------|----------| +| `as-needed` | Build only if image doesn't exist or source changed | Default, efficient | +| `build` | Always build from source | Force rebuild | +| `build-force` | Force rebuild, ignore cache | Clean rebuild | +| `prebuilt` | Use prebuilt images only | Production | +| `prebuilt-local` | Use local prebuilt images | Offline work | +| `prebuilt-remote` | Pull from remote registry | CI/CD | +| `fetch-repos` | Only clone repositories, no building | Repository setup | + +## Workflow + +The prepare command: +1. Clones required repositories (if needed) +2. Builds container images from source (based on policy) +3. Downloads prebuilt images (if specified) +4. Tags images appropriately +5. Optionally publishes to registry + +## Examples + +### Basic Usage + +```bash +# Prepare all containers for a stack +stack prepare --stack my-stack + +# Prepare with latest code +stack prepare --stack my-stack --git-pull + +# Prepare and publish +stack prepare --stack my-stack --publish-images --image-registry registry.example.com +``` + +### Selective Preparation + +```bash +# Only prepare specific containers +stack prepare --stack my-stack --include-containers frontend --include-containers backend + +# Exclude certain containers +stack prepare --stack my-stack --exclude-containers test-utils + +# Only clone repositories +stack prepare --stack my-stack --build-policy fetch-repos +``` + +### Build Policies + +```bash +# Force rebuild everything +stack prepare --stack my-stack --build-policy build-force + +# Use only prebuilt images +stack prepare --stack my-stack --build-policy prebuilt + +# Pull from remote registry +stack prepare --stack my-stack --build-policy prebuilt-remote +``` + +### Advanced Options + +```bash +# Prepare with custom build arguments +stack prepare --stack my-stack --extra-build-args "--build-arg VERSION=1.2.3" + +# Prepare for specific architecture +stack prepare --stack my-stack --target-arch arm64 --dont-pull-images + +# Prepare with SSH for private repos +stack prepare --stack my-stack --git-ssh --include-repos private-repo +``` + +## See Also + +- [stack build](build.md) - Build stack components +- [stack fetch](fetch.md) - Clone repositories +- [stack deploy](deploy.md) - Deploy a stack diff --git a/docs/commands/update.md b/docs/commands/update.md new file mode 100644 index 0000000..e2e1dbe --- /dev/null +++ b/docs/commands/update.md @@ -0,0 +1,66 @@ +# stack update + +Update shiv binary from a distribution URL + +## Synopsis + +```bash +stack update [OPTIONS] +``` + +## Description + +[Placeholder: Add detailed description of how the update command checks for and installs updates to the stack tool itself] + +## Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--check-only` | FLAG | Only check for updates, don't install | False | +| `--distribution-url` | TEXT | The distribution URL to check | From config or GitHub releases | + +## Default Distribution URL + +Default: `https://github.com/bozemanpass/stack/releases/latest/download/stack` + +## Update Process + +1. Check current version +2. Query distribution URL for latest version +3. Compare versions +4. Download new version if available +5. Replace current binary +6. Verify installation + +## Examples + +```bash +# Check for updates and install if available +stack update + +# Only check for updates (don't install) +stack update --check-only + +# Update from custom distribution +stack update --distribution-url https://myrepo.example.com/stack/latest + +# Configure custom distribution URL +stack config set distribution-url https://myrepo.example.com/stack/latest +stack update +``` + +## Version Information + +To check current version: +```bash +stack version +``` + +## Automatic Updates + +[Placeholder: Add information about automatic update checks if implemented] + +## See Also + +- [stack version](version.md) - Print tool version +- [stack config](config.md) - Manage configuration settings diff --git a/docs/commands/version.md b/docs/commands/version.md new file mode 100644 index 0000000..5d9fae5 --- /dev/null +++ b/docs/commands/version.md @@ -0,0 +1,49 @@ +# stack version + +Print tool version + +## Synopsis + +```bash +stack version +``` + +## Description + +[Placeholder: Add detailed description of version command output and version numbering scheme] + +## Output Format + +The version command outputs: +- Version number (e.g., `2.0.1`) +- Build hash (if available) +- Build timestamp (if available) + +Example output: +``` +stack version 2.0.1-d531f73-202505011750 +``` + +## Version Components + +- **Major version**: Breaking changes +- **Minor version**: New features +- **Patch version**: Bug fixes +- **Build hash**: Git commit hash +- **Timestamp**: Build date and time + +## Examples + +```bash +# Display version +stack version + +# Check version in scripts +if stack version | grep -q "2.0"; then + echo "Version 2.0 or higher" +fi +``` + +## See Also + +- [stack update](update.md) - Update shiv binary from a distribution URL diff --git a/docs/commands/webapp.md b/docs/commands/webapp.md new file mode 100644 index 0000000..7a39e18 --- /dev/null +++ b/docs/commands/webapp.md @@ -0,0 +1,158 @@ +# stack webapp + +Build, run, and deploy webapps + +## Synopsis + +```bash +stack webapp [OPTIONS] COMMAND [ARGS]... +``` + +## Description + +[Placeholder: Add detailed description of webapp-specific functionality for building and deploying web applications] + +## Subcommands + +### build + +Build the specified webapp container + +```bash +stack webapp build [OPTIONS] +``` + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--base-container` | TEXT | Base container image to use | - | +| `--source-repo` | TEXT | Directory containing the webapp to build (required) | - | +| `--force-rebuild` | FLAG | Override dependency checking -- always rebuild | False | +| `--extra-build-args` | TEXT | Supply extra arguments to build | - | +| `--tag` | TEXT | Container tag | `bozemanpass/:stack` | + +### deploy + +Create a deployment for the specified webapp container + +```bash +stack webapp deploy [OPTIONS] +``` + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--kube-config` | TEXT | Provide a config file for a k8s deployment | - | +| `--image-registry` | TEXT | Container image registry URL (required for k8s) | - | +| `--deployment-dir` | TEXT | Create deployment files in this directory (required) | - | +| `--image` | TEXT | Image to deploy (required) | - | +| `--url` | TEXT | URL to serve (required for k8s) | - | +| `--config-file` | TEXT | Environment file for webapp | - | + +### run + +Run the specified webapp container + +```bash +stack webapp run [OPTIONS] +``` + +#### Options + +| Option | Type | Description | Default | +|--------|------|-------------|---------| +| `--image` | TEXT | Image to deploy (required) | - | +| `--config-file` | TEXT | Environment file for webapp | - | +| `--port` | INTEGER | Port to use | Random | + +## Webapp Types + +Supported webapp frameworks: +- React +- Vue.js +- Angular +- Next.js +- Static HTML +- Node.js applications +- Python Flask/Django +- [Placeholder: Add other supported frameworks] + +## Build Process + +1. Analyze source repository +2. Detect framework type +3. Install dependencies +4. Build production assets +5. Create optimized container +6. Tag image appropriately + +## Examples + +### Building Webapps + +```bash +# Build a webapp from source +stack webapp build --source-repo ./my-react-app + +# Build with custom base image +stack webapp build --source-repo ./my-app --base-container node:18-alpine + +# Force rebuild +stack webapp build --source-repo ./my-app --force-rebuild + +# Build with custom tag +stack webapp build --source-repo ./my-app --tag myregistry/myapp:v1.0 +``` + +### Running Webapps + +```bash +# Run a webapp locally +stack webapp run --image myapp:latest + +# Run with specific port +stack webapp run --image myapp:latest --port 3000 + +# Run with environment file +stack webapp run --image myapp:latest --config-file .env.local +``` + +### Deploying Webapps + +```bash +# Deploy to Docker +stack webapp deploy \ + --image myapp:latest \ + --deployment-dir ~/deployments/myapp + +# Deploy to Kubernetes +stack webapp deploy \ + --image myapp:latest \ + --deployment-dir ~/deployments/myapp \ + --kube-config ~/.kube/config \ + --image-registry registry.example.com \ + --url https://myapp.example.com + +# Deploy with configuration +stack webapp deploy \ + --image myapp:latest \ + --deployment-dir ~/deployments/myapp \ + --config-file production.env +``` + +## Environment Configuration + +Environment files (`.env` format): +```env +NODE_ENV=production +API_URL=https://api.example.com +DATABASE_URL=postgres://... +``` + +## See Also + +- [stack build](build.md) - Build stack components +- [stack deploy](deploy.md) - Deploy a stack +- [stack manage](manage.md) - Manage a deployed stack