mirror of
https://github.com/mblanke/Lottery-Tracker.git
synced 2026-03-01 14:10:22 -05:00
4.7 KiB
4.7 KiB
🐋 Docker Setup Complete!
What's Been Created
Docker Files
- ✅
Dockerfile.backend- Flask API with Playwright - ✅
Dockerfile.frontend- Next.js app optimized for production - ✅
Dockerfile.email- Email scheduler service - ✅
docker-compose.yml- Development setup - ✅
docker-compose.prod.yml- Production setup with nginx - ✅
.dockerignore- Optimized build context - ✅
requirements.txt- Python dependencies
Configuration
- ✅ Updated
next.config.tsfor standalone output - ✅ Created startup scripts (Windows & Linux)
- ✅ Complete documentation in
DOCKER_README.md
🚀 Quick Start
Option 1: Windows Script (Easiest)
docker-start.bat
Option 2: Docker Compose
docker-compose up -d
Option 3: Manual Build
# Build
docker-compose build
# Start
docker-compose up -d
# Check status
docker-compose ps
📦 What Gets Deployed
Backend Container
- Python 3.13
- Flask API on port 5000
- Playwright with Chromium browser
- Lottery scrapers for all 4 lotteries
- Investment calculator
- Health check endpoint
Frontend Container
- Node.js 20
- Next.js standalone build
- Optimized production bundle
- Connects to backend API
Email Container (Optional)
- Runs daily at 7:00 AM
- Sends lottery jackpot emails
- Uses same scraping logic
🌐 Access Points
After running docker-compose up -d:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Health Check: http://localhost:5000/api/health
📊 Container Management
View Logs
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f backend
docker-compose logs -f frontend
Restart Services
docker-compose restart
Stop Everything
docker-compose down
Rebuild After Changes
docker-compose up -d --build
🔧 Troubleshooting
Port Already in Use
If ports 3000 or 5000 are busy:
Option A: Stop other services
# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F
Option B: Change ports in docker-compose.yml
ports:
- "8080:3000" # Use port 8080 instead
Backend Won't Start
# Check logs
docker logs lottery-backend
# Rebuild without cache
docker-compose build --no-cache backend
Frontend Can't Connect
Update docker-compose.yml frontend environment:
environment:
- NEXT_PUBLIC_API_URL=http://localhost:5000
🎯 Include Email Scheduler
To run the email scheduler:
docker-compose --profile email up -d
Or remove the profiles section from docker-compose.yml to always include it.
📈 Production Deployment
Use Production Compose
docker-compose -f docker-compose.prod.yml up -d
Deploy to Server
# On your server
git clone <your-repo>
cd Lottery
docker-compose -f docker-compose.prod.yml up -d
Push to Docker Hub
# Login
docker login
# Tag images
docker tag lottery-backend yourusername/lottery-backend:latest
docker tag lottery-frontend yourusername/lottery-frontend:latest
# Push
docker push yourusername/lottery-backend:latest
docker push yourusername/lottery-frontend:latest
🔒 Security for Production
- Use environment variables - Don't hardcode credentials
- Enable HTTPS - Use nginx with SSL certificates
- Update base images regularly
- Scan for vulnerabilities:
docker scan lottery-backend - Use Docker secrets for sensitive data
💾 Data Persistence
Currently, containers are stateless. To add persistence:
Add volumes in docker-compose.yml:
volumes:
- ./data:/app/data
🎛️ Resource Limits
Current limits (production):
- Backend: 2GB RAM, 1 CPU
- Frontend: 512MB RAM, 0.5 CPU
- Email: 1GB RAM, 0.5 CPU
Adjust in docker-compose.prod.yml if needed.
✅ Benefits of Docker
- ✅ Consistent environment - Works the same everywhere
- ✅ Easy deployment - One command to start everything
- ✅ Isolation - Each service in its own container
- ✅ Scalability - Easy to scale services
- ✅ Version control - Docker images are versioned
- ✅ Portability - Deploy anywhere Docker runs
📝 Next Steps
- ✅ Test locally:
docker-compose up -d - ✅ Check logs:
docker-compose logs -f - ✅ Access app: http://localhost:3000
- ✅ Configure email scheduler if needed
- ✅ Deploy to production server
- ✅ Set up CI/CD pipeline (optional)
🆘 Need Help?
See detailed documentation in:
DOCKER_README.md- Full Docker guideEMAIL_SETUP.md- Email configuration- Docker logs:
docker-compose logs -f
Enjoy your Dockerized Lottery Investment Calculator! 🎰🐋