Add comprehensive production deployment infrastructure with Docker auto-restart and systemd on-boot startup capabilities. Changes: - Add deploy-production-docker.sh: Automated deployment script with Docker validation - Add install-systemd-service.sh: Systemd service installer for auto-start on boot - Add scripts/mev-bot.service: Systemd service definition for MEV bot - Update docker-compose.yml: Enable logs volume mount and metrics port - Update PRODUCTION_QUICKSTART.md: Simplified deployment documentation Features: - Docker auto-restart on failure (restart: always policy) - Systemd auto-start on system boot - Persistent logs via volume mount - Health checks and resource limits - Comprehensive deployment validation - Easy-to-use installation scripts Usage: ./scripts/deploy-production-docker.sh # Deploy with Docker sudo ./scripts/install-systemd-service.sh # Enable auto-start on boot 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.9 KiB
5.9 KiB
MEV Bot - Production Quick Start
This guide will help you deploy the MEV Bot in production with Docker, auto-restart, and on-boot capabilities.
Prerequisites
- Docker and Docker Compose installed
- Git repository cloned
- Root/sudo access (for systemd auto-start on boot)
Quick Deployment
Option 1: One-Step Deployment (Recommended)
# Run the simplified deployment script
./scripts/deploy-production-docker.sh
This script will:
- Verify Docker and Docker Compose are installed
- Create/verify
.envfile from.env.productionor.env.example - Build the Docker image
- Start the container with auto-restart (
restart: always) - Provide instructions for systemd auto-start on boot
For auto-start on boot (requires sudo):
sudo ./scripts/install-systemd-service.sh
Option 2: Manual Deployment
# 1. Create environment file
cp .env.production .env # or use .env.example
nano .env # Edit with your configuration if needed
# 2. Build and start with auto-restart
docker compose up -d
# 3. Setup auto-start on boot (optional)
sudo ./scripts/install-systemd-service.sh
Configuration
Edit .env file with your settings:
# Required: Update with your RPC endpoint
ARBITRUM_RPC_ENDPOINT=https://arbitrum-rpc.publicnode.com
# Optional: Adjust log level
LOG_LEVEL=info
# Optional: Change port
PORT=8080
Verify Deployment
# Check container status
docker compose ps
# View logs
docker compose logs -f mev-bot
# Check health
curl http://localhost:8080/health
# View systemd status (if configured)
sudo systemctl status mev-bot
Production Features
The production deployment includes:
- Auto-Restart: Container restarts automatically on failure (
restart: always) - Auto-Start on Boot: Systemd service starts container on system boot
- Health Checks: Automatic health monitoring every 30 seconds
- Resource Limits: CPU and memory limits to prevent resource exhaustion
- Security Hardening: Runs as non-root user with minimal privileges
- Read-Only Config: Configuration mounted as read-only
Managing the Bot
Docker Compose Commands
# View logs (follow mode)
docker compose logs -f mev-bot
# Restart
docker compose restart mev-bot
# Stop
docker compose down
# Update and restart
git pull origin master
docker compose up -d --build
# View container stats
docker stats mev-bot-production
Systemd Commands (if configured)
# Check status
sudo systemctl status mev-bot
# Restart
sudo systemctl restart mev-bot
# Stop
sudo systemctl stop mev-bot
# View logs
journalctl -u mev-bot -f
# Disable auto-start
sudo systemctl disable mev-bot
Monitoring
Container Logs
# Live logs
docker compose logs -f mev-bot
# Last 100 lines
docker compose logs --tail=100 mev-bot
# Logs since 1 hour ago
docker compose logs --since 1h mev-bot
Health Check
# Simple health check
curl http://localhost:8080/health
# Expected response: {"status": "ok"} or similar
Resource Usage
# Real-time stats
docker stats mev-bot-production
# Shows: CPU %, Memory, Network I/O, Block I/O
Troubleshooting
Container won't start
# Check logs for errors
docker compose logs mev-bot
# Verify .env file exists and is configured
cat .env
# Check if port is already in use
sudo netstat -tulpn | grep 8080
Auto-start not working
# Verify systemd service is enabled
sudo systemctl is-enabled mev-bot
# Check service status
sudo systemctl status mev-bot
# View systemd logs
journalctl -u mev-bot -n 50
High resource usage
# Check current usage
docker stats mev-bot-production
# Adjust limits in docker-compose.yml:
# deploy.resources.limits.cpus
# deploy.resources.limits.memory
Updating the Bot
Manual Updates
# Pull latest code
git pull origin master
# Rebuild and restart
docker compose up -d --build
# Or using systemd
sudo systemctl reload mev-bot
Automatic Updates (Recommended)
Setup auto-updates to automatically pull, rebuild, and restart when master branch changes:
# Enable auto-updates
sudo ./scripts/setup-auto-update.sh
This enables:
- ✅ Auto-rebuild after manual
git pull - ✅ Periodic update checks every 5 minutes
- ✅ Automatic pull, rebuild, and restart
- ✅ Detailed logging of all updates
Manage auto-updates:
# Check auto-update status
sudo systemctl status mev-bot-auto-update.timer
# View auto-update logs
tail -f logs/auto-update.log
# Disable auto-updates
sudo systemctl stop mev-bot-auto-update.timer
# Enable auto-updates
sudo systemctl start mev-bot-auto-update.timer
For complete auto-update documentation, see AUTO_UPDATE_GUIDE.md
Security Best Practices
- Never commit
.envfile - It's in.gitignore - Use strong RPC credentials - Keep API keys secure
- Restrict network access - Use firewall rules
- Monitor logs regularly - Check for suspicious activity
- Keep system updated - Update Docker and dependencies
Support
For detailed deployment options, monitoring, and advanced configuration, see:
- DEPLOYMENT_GUIDE.md - Comprehensive deployment guide
- README.md - Project overview
Quick Command Reference
# Deploy
sudo ./scripts/deploy-production.sh
sudo ./scripts/setup-auto-update.sh # Add auto-updates
# Status
docker compose ps
sudo systemctl status mev-bot
sudo systemctl status mev-bot-auto-update.timer # Auto-update status
# Logs
docker compose logs -f mev-bot
journalctl -u mev-bot -f
tail -f logs/auto-update.log # Auto-update logs
# Restart
docker compose restart mev-bot
sudo systemctl restart mev-bot
# Stop
docker compose down
sudo systemctl stop mev-bot
# Update (Manual)
git pull && docker compose up -d --build
# Update (Auto - happens automatically)
./scripts/auto-update.sh # Trigger manual update check