CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a Crystal Language project called "mangrullo" - a Docker container update automation tool similar to Watchtower. The project is functional and includes container monitoring, update detection, container recreation, and filtering capabilities. It follows standard Crystal conventions with comprehensive tests and a modular architecture.
Development Commands
Building and Running
crystal build src/mangrullo.cr
- Compile the CLIcrystal build src/web_baked.cr
- Compile the web interfacecrystal run src/mangrullo.cr
- Run the CLIcrystal run src/web_baked.cr
- Run the web interfaceshards build
- Build all targetsshards build mangrullo
- Build CLI targetshards build mangrullo-web
- Build web interface targetcrystal tool format
- Format code according to Crystal style guidelinesameba --fix
- Fix linting issues automatically
Testing
crystal spec
- Run all tests (56 examples)crystal spec spec/mangrullo_spec.cr
- Run main test filecrystal spec --verbose
- Run tests with detailed output
Dependencies
shards install
- Install dependencies from shard.ymlshards build
- Build all targets using shardsshards build mangrullo
- Build CLI targetshards build mangrullo-web
- Build web interface target
Project Structure
Source Files
src/mangrullo.cr
- Main CLI entry pointsrc/cli.cr
- CLI interface and main loopsrc/config.cr
- Configuration management using Docoptsrc/types.cr
- Core data structures and version comparisonsrc/docker_client.cr
- Docker API wrapper and container operationssrc/image_checker.cr
- Image update detection and registry accesssrc/update_manager.cr
- Update coordination with container filteringsrc/web_baked.cr
- Web interface entry point with baked assetssrc/web_server_baked.cr
- Kemal web server with embedded static filessrc/web_views.cr
- Web interface templates with auto-refreshsrc/static_assets.cr
- Embedded CSS, JavaScript, and imagessrc/state_manager.cr
- Shared state management for web interfacesrc/container_state.cr
- Container state data structuressrc/error_handling.cr
- Centralized error management
Configuration
shard.yml
- Project dependencies and build targetsspec/mangrullo_spec.cr
- Comprehensive test suite (56 examples)spec/spec_helper.cr
- Test configuration
Key Features Implemented
- Container Monitoring: Automatically detects running Docker containers
- Update Detection: Compares local and remote image versions/digests
- Container Filtering: Check specific containers by name with flexible matching
- Container Recreation: Properly recreates containers with new images (like Watchtower)
- Multi-Registry Support: Docker Hub, GHCR, lscr.io (with proper mapping)
- Semantic Versioning: Intelligent version comparison with major upgrade control
- Dry Run Mode: Test updates without making changes with comprehensive results modal
- Full Web Interface: Complete web-based monitoring and management dashboard
- Bulk Operations: Update multiple containers with dry run and major version controls
- Custom Branding: Cell tower icons and favicon throughout interface
- Typography: Chivo and Chivo Mono Google Fonts integration for enhanced readability
- Auto-refresh Dashboard: Real-time container status updates every 30 seconds
- Embedded Static Assets: All web assets baked into binary for easy deployment
- Button State Management: Proper onclick attribute handling to prevent double operations
- Critical Bug Fixes: JSON parameter parsing fix for dry run functionality
- Rate Limiting Protection: 6-hour default interval to avoid Docker Hub limits
- Multi-architecture Builds: Static binaries for Linux AMD64 and ARM64
- Comprehensive Testing: Unit tests for all major functionality (155 examples passing)
- CI/CD Integration: GitHub Actions with Ameba linting and automated testing
Code Style
Follow Crystal Language conventions:
- Use 2-space indentation
- Module names are CamelCase
- Constants are UPPER_SNAKE_CASE
- Method names are snake_case
- Use
crystal tool format
for formatting - Avoid
not_nil!
- use proper nilable handling - Prefer
unless
overif !
for negative conditions
Current State
The project is fully functional with:
- Complete CLI implementation with all planned features
- Container recreation that properly updates containers (not just restart)
- Flexible container name matching (handles both "name" and "/name")
- Comprehensive test suite (56 examples, 0 failures)
- Web interface framework in place
- Multi-registry support with authentication
- Proper error handling and logging
Project Dependencies
From shard.yml
:
docr
- Docker API clientdocopt
- Command-line parsingkemal
- Web frameworkkilt
- Template enginebaked_file_system
- Embedded file system for static assetsbaked_file_handler
- Handler for baked files in Kemalprogress
- Progress bars for CLI operations
Crystal Version
This project requires Crystal >= 1.16.3 (developed with Crystal 1.17.1).