#!/bin/bash # Development environment helper script # Ensures all development happens within containers set -e PROJECT_ROOT="/docker/mev-beta" cd "$PROJECT_ROOT" || exit 1 # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color info() { echo -e "${BLUE}ℹ${NC} $1"; } success() { echo -e "${GREEN}✓${NC} $1"; } warn() { echo -e "${YELLOW}⚠${NC} $1"; } error() { echo -e "${RED}✗${NC} $1"; } # Show usage usage() { cat < Container Development Commands: up Start all development containers down Stop all development containers restart Restart all development containers go Enter Go development container python Enter Python development container foundry Enter Foundry container build Build Go application in container test [type] Run tests (all, unit, integration, race, bench, coverage) audit Run comprehensive codebase audit check-docs Check documentation coverage check-compliance Check SPEC.md compliance forge-build Build Solidity contracts in container forge-test Run Foundry tests in container bindings Generate Go bindings from ABIs in container clean Clean all build artifacts reset Stop containers and clean artifacts logs [service] View logs for a service (go-dev, foundry, mev-bot-v2, etc.) ps Show running containers Examples: ./scripts/dev.sh up # Start dev environment ./scripts/dev.sh go # Enter Go container ./scripts/dev.sh build # Build bot in Go container ./scripts/dev.sh test all # Run all tests ./scripts/dev.sh test coverage # Generate coverage report ./scripts/dev.sh audit # Run security & quality audit ./scripts/dev.sh check-compliance # Check SPEC.md compliance ./scripts/dev.sh forge-build # Build contracts ./scripts/dev.sh bindings # Generate bindings in Go container EOF exit 0 } # Check if command is provided if [ $# -eq 0 ]; then usage fi COMMAND=$1 shift case "$COMMAND" in up) info "Starting development containers..." podman-compose up -d go-dev python-dev foundry success "Development environment ready" info "Available containers:" echo " - mev-go-dev : Go 1.21" echo " - mev-python-dev : Python 3.11" echo " - mev-foundry : Foundry tools" ;; down) info "Stopping development containers..." podman-compose stop go-dev python-dev foundry 2>/dev/null || true success "Development containers stopped" ;; restart) info "Restarting development containers..." podman-compose restart go-dev python-dev foundry success "Development containers restarted" ;; go) info "Entering Go development container..." podman exec -it mev-go-dev sh ;; python) info "Entering Python development container..." podman exec -it mev-python-dev bash ;; foundry) info "Entering Foundry container..." podman exec -it mev-foundry sh ;; build) info "Building Go application in container..." podman exec -it mev-go-dev sh -c "cd /workspace && go build -o bin/mev-bot ./cmd/mev-bot/main.go" success "Build complete: bin/mev-bot" ;; test) info "Running test suite..." ./scripts/test.sh "$@" ;; audit) info "Running codebase audit..." ./scripts/audit.sh ;; check-docs) info "Checking documentation coverage..." ./scripts/check-docs.sh ;; check-compliance) info "Checking SPEC.md compliance..." ./scripts/check-compliance.sh ;; forge-build) info "Building Solidity contracts in Foundry container..." podman exec -it mev-foundry sh -c "cd /workspace/contracts && forge build" success "Contracts built: contracts/out/" ;; forge-test) info "Running Foundry tests in container..." podman exec -it mev-foundry sh -c "cd /workspace/contracts && forge test -vv $*" ;; bindings) info "Generating Go bindings from contract ABIs..." podman exec -it mev-go-dev sh -c "cd /workspace && ./scripts/generate-bindings-in-container.sh" success "Bindings generated in bindings/" ;; clean) info "Cleaning build artifacts..." rm -rf bin/mev-bot rm -rf contracts/out rm -rf contracts/cache success "Build artifacts cleaned" ;; reset) warn "Stopping containers and cleaning artifacts..." podman-compose stop go-dev python-dev foundry 2>/dev/null || true rm -rf bin/mev-bot rm -rf contracts/out rm -rf contracts/cache success "Environment reset" ;; logs) SERVICE="${1:-go-dev}" info "Showing logs for $SERVICE..." podman-compose logs -f "$SERVICE" ;; ps) info "Running containers:" podman-compose ps ;; help|--help|-h) usage ;; *) error "Unknown command: $COMMAND" echo "" usage ;; esac