Skip to content

mlnj/crush-machine

Repository files navigation

Crush Machine

A Docker-based wrapper for running @charmland/crush in an isolated Debian environment. This tool allows you to run crush commands on any directory by automatically mounting it into a containerized environment.

Features

  • 🐳 Docker-based isolation - Runs crush in a clean Debian container
  • 📦 Pre-configured environment - Node.js 21 and @charmland/crush pre-installed
  • 🔄 Automatic cleanup - Containers are automatically removed after execution
  • 🎲 Unique container names - Each run gets a randomly named container (e.g., crush-machine-swift-dragon-12345)
  • 📁 Directory mounting - Mount any local directory into the container
  • 💾 Persistent data - Automatically mounts ~/.local/share/crush for crush's local data
  • 🌐 Global installation - Install once, use from anywhere

Requirements

  • Docker and Docker Compose installed and running
  • Bash shell
  • Write access to /usr/local/bin or ~/.local/bin (for global installation)

Installation

Global Installation (Recommended)

Install the crusher command globally so you can use it from anywhere:

./install.sh

This will:

  • Copy crusher.sh to /usr/local/bin/crusher (or ~/.local/bin/crusher if /usr/local/bin is not writable)
  • Copy crush-machine.yml and crush-machine.dockerfile to the same directory
  • Make the command executable

After installation, verify it works:

crusher --help

Manual Usage

You can also use the script directly without installation:

./crusher.sh [directory]

Usage

Basic Usage

Run crush on the current directory:

crusher

Run crush on a specific directory:

crusher /path/to/directory

How It Works

  1. Container Creation: Creates a uniquely named Docker container using docker-compose
  2. Directory Mounting: Mounts your specified directory to /workspace in the container
  3. Data Persistence: Mounts ~/.local/share/crush to preserve crush's local state
  4. Execution: Runs the crush command inside the container
  5. Cleanup: Automatically removes the container when the command completes

Container Naming

Each container gets a unique name combining:

  • Base name: crush-machine
  • Random adjective-noun pair (e.g., swift-dragon, cosmic-phoenix)
  • Process ID: $$

Example: crush-machine-neon-tiger-12345

Project Structure

crush-machine/
├── crusher.sh                 # Main script that orchestrates the container
├── crush-machine.yml          # Docker Compose configuration
├── crush-machine.dockerfile   # Docker image definition
├── install.sh                 # Installation script
├── uninstall.sh               # Uninstallation script
└── README.md                  # This file

Docker Image

The Docker image is based on Debian and includes:

  • Basic utilities (curl, git, vim, wget)
  • Node.js 21
  • @charmland/crush (installed globally)

Uninstallation

To remove the globally installed crusher command:

./uninstall.sh

This removes:

  • The crusher command
  • crush-machine.yml
  • crush-machine.dockerfile

Troubleshooting

Container not starting

Ensure Docker is running:

docker ps

Permission denied

If you get permission errors, try installing to ~/.local/bin:

mkdir -p ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
./install.sh

Container name conflicts

Each container gets a unique name, so conflicts are unlikely. If you see errors about existing containers, you can manually remove them:

docker ps -a | grep crush-machine
docker rm <container-id>

Development

To modify the Docker environment, edit crush-machine.dockerfile and rebuild:

docker compose -f crush-machine.yml build

License

This project is provided as-is for use with @charmland/crush.

Related Projects

About

A simple sandbox for Crush CLI

Resources

License

Stars

Watchers

Forks