Files
mev-beta/orig/PRODUCTION_QUICKSTART.md
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

286 lines
5.9 KiB
Markdown

# 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)
```bash
# Run the simplified deployment script
./scripts/deploy-production-docker.sh
```
This script will:
1. Verify Docker and Docker Compose are installed
2. Create/verify `.env` file from `.env.production` or `.env.example`
3. Build the Docker image
4. Start the container with auto-restart (`restart: always`)
5. Provide instructions for systemd auto-start on boot
**For auto-start on boot (requires sudo):**
```bash
sudo ./scripts/install-systemd-service.sh
```
### Option 2: Manual Deployment
```bash
# 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:
```bash
# 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
```bash
# 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
```bash
# 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)
```bash
# 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
```bash
# 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
```bash
# Simple health check
curl http://localhost:8080/health
# Expected response: {"status": "ok"} or similar
```
### Resource Usage
```bash
# Real-time stats
docker stats mev-bot-production
# Shows: CPU %, Memory, Network I/O, Block I/O
```
## Troubleshooting
### Container won't start
```bash
# 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
```bash
# 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
```bash
# 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
```bash
# 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:
```bash
# 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:**
```bash
# 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](AUTO_UPDATE_GUIDE.md)
## Security Best Practices
1. **Never commit `.env` file** - It's in `.gitignore`
2. **Use strong RPC credentials** - Keep API keys secure
3. **Restrict network access** - Use firewall rules
4. **Monitor logs regularly** - Check for suspicious activity
5. **Keep system updated** - Update Docker and dependencies
## Support
For detailed deployment options, monitoring, and advanced configuration, see:
- [DEPLOYMENT_GUIDE.md](docs/DEPLOYMENT_GUIDE.md) - Comprehensive deployment guide
- [README.md](README.md) - Project overview
## Quick Command Reference
```bash
# 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
```