Skip to content

Conversation

@cj4c0b1
Copy link
Contributor

@cj4c0b1 cj4c0b1 commented Oct 13, 2025

🐳 Docker Implementation

Fixes #71

This PR adds complete Docker support for the Aster Lick Hunter Node project, making deployment significantly easier and more reliable.

📦 What's New

Core Docker Files

  • Dockerfile - Multi-stage production build with security best practices
  • docker-compose.yml - Production deployment configuration
  • docker-compose.dev.yml - Development mode with hot reload
  • .dockerignore - Optimized build context
  • docker-entrypoint.sh - Container initialization and setup

Developer Tools

  • Makefile - Convenient commands (make up, make logs, make backup, etc.)
  • docker-start.sh - Interactive setup wizard
  • .env.example - Environment variable template

Documentation

  • docs/DOCKER.md - Comprehensive 400+ line deployment guide
  • DOCKER_SETUP_SUMMARY.md - Implementation overview
  • README.md - Updated with Docker installation instructions

CI/CD

  • .github/workflows/docker-build.yml - Automated Docker builds and tests

API Endpoints

  • /api/health - Health check endpoint for monitoring

✨ Features

Security

  • ✅ Non-root user (nextjs:nodejs, UID/GID 1001)
  • ✅ Multi-stage builds for minimal image size
  • ✅ Read-only mounts where appropriate
  • ✅ Environment variable secrets

Reliability

  • ✅ Health checks every 30s
  • ✅ Auto-restart on failure
  • ✅ Data persistence with volumes
  • ✅ Graceful shutdown handling

Developer Experience

  • ✅ One-command setup: make up
  • ✅ Interactive script: ./docker-start.sh
  • ✅ Development mode with hot reload
  • ✅ Easy backup/restore: make backup

🚀 Quick Start

Using Makefile (Recommended)

make build    # Build Docker image
make up       # Start containers
make logs     # View logs
make health   # Check status

Using Docker Compose

docker-compose up -d

Using Interactive Script

./docker-start.sh

🔧 Configuration

Environment Variables

  • NEXTAUTH_SECRET - Session encryption secret (required)
  • NEXT_PUBLIC_WS_HOST - WebSocket host (default: localhost)
  • DASHBOARD_PORT - Dashboard port (default: 3000)
  • WEBSOCKET_PORT - WebSocket port (default: 8080)

Volume Mounts

  • ./data:/app/data - Database and application data
  • ./.env.local:/app/.env.local - Environment variables

🐛 Bug Fixes

This PR also includes fixes for:

  • ✅ Postinstall script errors during Docker build
  • ✅ TypeScript build errors (undefined leverage, unused variables)
  • ✅ Config file initialization issues
  • ✅ Container restart loops

📊 Testing

Container Status: Healthy and running
Dashboard: http://localhost:3000 (accessible)
Health API: http://localhost:3000/api/health (passing)
WebSocket: ws://localhost:8080 (operational)
Bot: Running in paper mode with simulated liquidations

Performance Metrics:

  • CPU Usage: ~1%
  • Memory: ~313 MiB
  • Image Size: 1.2 GB (optimized with multi-stage build)

📚 Documentation

See docs/DOCKER.md for:

  • Detailed installation instructions
  • Configuration options
  • Production deployment guide
  • Troubleshooting tips
  • Backup and restore procedures

🎯 Benefits

For Users

  • Easier Setup - No Node.js installation required
  • Isolated Environment - No conflicts with system packages
  • Consistent - Same environment everywhere
  • Portable - Run anywhere Docker runs
  • Safe - Easy rollback and recovery

For Developers

  • Reproducible - Same environment for all developers
  • Fast Deployment - One command to deploy
  • Easy Testing - Spin up/down quickly
  • CI/CD Ready - Automated builds and tests
  • Scalable - Easy to add more services

📝 Breaking Changes

None - This is purely additive. Existing installation methods continue to work.

🔗 Related Issues

Closes #71

- Changed PNL percentage calculation to use margin instead of notional value
- Updated both server-side (API) and client-side (PositionTable) calculations
- Now matches aster.dex ROE calculation: (unrealizedPnl / margin) * 100
- Fixes issue CryptoGnome#66
- Add OPTIMIZER_SELECTED_SYMBOLS environment variable support
- Pass selected symbols from optimizer job to optimize-config.js
- Improve logging and progress reporting during optimization
- Add production-ready Dockerfile with multi-stage builds
- Add docker-compose.yml for easy deployment
- Add docker-compose.dev.yml for development mode
- Add .dockerignore for optimized builds
- Add docker-entrypoint.sh for container initialization
- Add health check API endpoint at /api/health
- Add comprehensive Docker documentation (docs/DOCKER.md)
- Add Makefile with convenient Docker commands
- Add docker-start.sh interactive setup script
- Add GitHub Actions workflow for Docker builds
- Add .env.example template
- Update README.md with Docker installation instructions

Features:
- Multi-stage build for optimal image size
- Non-root user for security
- Volume mounts for data persistence
- Health checks for monitoring
- Development and production modes
- Automatic configuration setup
- Easy backup and restore commands
- Remove 'version' attribute from docker-compose.yml
- Remove 'version' attribute from docker-compose.dev.yml
- Add DOCKER_SETUP_SUMMARY.md with comprehensive overview

Docker Compose v2 no longer requires the version attribute and shows warnings when present.
- Fix postinstall script by copying scripts directory before npm install
- Add leverage variable to positionManager TP check
- Fix unused notionalValue variable in positions API
- Replace logWithTrace with logWithTimestamp
- Remove config.user.json volume mount to prevent directory creation
- Update entrypoint to create config.user.json from defaults
- Successfully tested: container runs healthy with dashboard accessible

Docker container now starts successfully and passes health checks.
Dashboard accessible at http://localhost:3000
WebSocket available at ws://localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Docker Container

1 participant