mirror of
https://github.com/mblanke/Lottery-Tracker.git
synced 2026-03-01 06:00:21 -05:00
3.7 KiB
3.7 KiB
Lottery Investment Calculator - Docker Setup
Prerequisites
- Docker Desktop installed (https://www.docker.com/products/docker-desktop)
- Docker Compose (included with Docker Desktop)
Quick Start
1. Configure Environment
cp .env.example .env
# Edit .env with your preferred settings
2. Build and Run
docker compose up -d
This starts:
- Backend API on http://localhost:5000
- Frontend Web App on http://localhost:3000
3. Check Status
docker compose ps
4. View Logs
# All services
docker compose logs -f
# Specific service
docker compose logs -f backend
docker compose logs -f frontend
5. Stop
docker compose down
Individual Services
Backend Only
docker build -f Dockerfile.backend -t lottery-backend .
docker run -p 5000:5000 --env-file .env lottery-backend
Frontend Only
docker build -f Dockerfile.frontend -t lottery-frontend .
docker run -p 3000:3000 lottery-frontend
Configuration
All configuration is done via environment variables. See .env.example for available options.
Key variables:
| Variable | Default | Description |
|---|---|---|
FLASK_DEBUG |
false |
Enable Flask debug mode |
FLASK_CORS_ORIGINS |
* |
Allowed CORS origins |
FEDERAL_TAX_RATE |
0.37 |
US federal tax rate |
DEFAULT_STATE_TAX_RATE |
0.055 |
Default state tax rate |
USD_TO_CAD |
1.44 |
USD→CAD exchange rate |
CACHE_TTL_HOURS |
6 |
Jackpot cache duration |
Network
Internal URLs (container to container)
- Backend:
http://backend:5000 - Frontend:
http://frontend:3000
External URLs (host machine)
- Backend:
http://localhost:5000 - Frontend:
http://localhost:3000
Health Checks
curl http://localhost:5000/api/health
Production Deployment
Using Production Compose
docker compose -f docker-compose.prod.yml up -d
This adds nginx reverse proxy with:
- Rate limiting (10 req/s)
- Static asset caching
- HTTPS support (configure certs in
ssl/) - Resource limits per container
See ssl/README.md for certificate setup.
Deploy to Server
git clone <your-repo>
cd Lottery-Tracker
cp .env.example .env
# Edit .env for production
docker compose -f docker-compose.prod.yml up -d
Push to Docker Hub
docker login
docker tag lottery-backend yourusername/lottery-backend:latest
docker tag lottery-frontend yourusername/lottery-frontend:latest
docker push yourusername/lottery-backend:latest
docker push yourusername/lottery-frontend:latest
Troubleshooting
Port Already in Use
# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F
# Or change ports in docker-compose.yml
Backend Won't Start
docker logs lottery-backend
docker compose build --no-cache backend
Frontend Can't Connect to Backend
docker compose ps
curl http://localhost:5000/api/health
docker exec lottery-frontend env | grep API_URL
Playwright Browser Issues
docker compose build --no-cache backend
docker exec lottery-backend playwright --version
Access Container Shell
docker exec -it lottery-backend /bin/bash
docker exec -it lottery-frontend /bin/sh
Clean Everything
docker compose down -v --rmi all
docker system prune -a
Resource Usage
Production limits (set in docker-compose.prod.yml):
- Backend: 2 GB RAM, 1 CPU
- Frontend: 512 MB RAM, 0.5 CPU
- Nginx: 256 MB RAM, 0.25 CPU
Monitor
docker stats
Image Sizes (Approximate)
- Backend: ~1.5 GB (includes Chromium for Playwright)
- Frontend: ~200 MB (Next.js standalone)
- Nginx: ~30 MB