|
| 1 | +# Deployment Guide |
| 2 | + |
| 3 | +This repository is configured for seamless deployment on multiple platforms. |
| 4 | + |
| 5 | +## 🚀 Vercel Deployment (Recommended) |
| 6 | + |
| 7 | +### Quick Deploy |
| 8 | + |
| 9 | +1. **Install Vercel CLI** (optional, for local testing): |
| 10 | + ```bash |
| 11 | + npm install -g vercel |
| 12 | + ``` |
| 13 | + |
| 14 | +2. **Deploy to Vercel**: |
| 15 | + ```bash |
| 16 | + # Login to Vercel |
| 17 | + vercel login |
| 18 | + |
| 19 | + # Deploy |
| 20 | + vercel |
| 21 | + ``` |
| 22 | + |
| 23 | +3. **Or use the Vercel Dashboard**: |
| 24 | + - Go to [vercel.com](https://vercel.com) |
| 25 | + - Import your GitHub repository |
| 26 | + - Vercel will automatically detect the `vercel.json` configuration |
| 27 | + - Click "Deploy" |
| 28 | + |
| 29 | +### What Gets Deployed |
| 30 | + |
| 31 | +- **Frontend**: `index.html` - Interactive dashboard |
| 32 | +- **API Endpoints**: |
| 33 | + - `GET /api/health` - Health check |
| 34 | + - `GET /api/status` - Repository status |
| 35 | + - `GET /api/lessons` - List all lessons |
| 36 | + - `GET /api/run?script=<name>` - Run Python scripts |
| 37 | + |
| 38 | +### Local Testing |
| 39 | + |
| 40 | +```bash |
| 41 | +# Install Vercel CLI |
| 42 | +npm install -g vercel |
| 43 | + |
| 44 | +# Run locally |
| 45 | +vercel dev |
| 46 | +``` |
| 47 | + |
| 48 | +Visit `http://localhost:3000` to test. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## 🐙 GitHub Actions Workflow |
| 53 | + |
| 54 | +The repository includes a CI/CD workflow that: |
| 55 | + |
| 56 | +1. **Tests** on Python 3.9, 3.10, 3.11, 3.12 |
| 57 | +2. **Runs linting** with flake8 |
| 58 | +3. **Checks formatting** with black |
| 59 | +4. **Executes tests** with pytest |
| 60 | +5. **Verifies Vercel deployment** readiness |
| 61 | + |
| 62 | +### Workflow Triggers |
| 63 | + |
| 64 | +- Push to `main` or `master` branch |
| 65 | +- Pull requests |
| 66 | +- Manual trigger via GitHub Actions UI |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## 🔧 Alternative Deployment Options |
| 71 | + |
| 72 | +### Docker |
| 73 | + |
| 74 | +Create a `Dockerfile`: |
| 75 | + |
| 76 | +```dockerfile |
| 77 | +FROM python:3.11-slim |
| 78 | + |
| 79 | +WORKDIR /app |
| 80 | +COPY . . |
| 81 | + |
| 82 | +RUN pip install --no-cache-dir -r requirements.txt |
| 83 | + |
| 84 | +EXPOSE 8000 |
| 85 | +CMD ["python", "-m", "http.server", "8000"] |
| 86 | +``` |
| 87 | + |
| 88 | +### Netlify |
| 89 | + |
| 90 | +1. Connect your GitHub repository |
| 91 | +2. Set build command: `echo "No build needed"` |
| 92 | +3. Set publish directory: `/` |
| 93 | +4. Add serverless functions in `api/` directory |
| 94 | + |
| 95 | +### Render |
| 96 | + |
| 97 | +1. Create new Web Service |
| 98 | +2. Connect GitHub repository |
| 99 | +3. Build Command: `pip install -r requirements.txt` |
| 100 | +4. Start Command: `python -m http.server $PORT` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## 📁 Project Structure |
| 105 | + |
| 106 | +``` |
| 107 | +├── api/ # Vercel serverless functions |
| 108 | +│ └── __init__.py # API endpoints |
| 109 | +├── .github/workflows/ # GitHub Actions CI/CD |
| 110 | +│ └── python-package.yml |
| 111 | +├── 01-basics/ # Lesson modules |
| 112 | +├── 02-data-types/ |
| 113 | +├── ... |
| 114 | +├── projects/ # Example projects |
| 115 | +├── index.html # Frontend dashboard |
| 116 | +├── vercel.json # Vercel configuration |
| 117 | +├── requirements.txt # Python dependencies |
| 118 | +└── README.md # Documentation |
| 119 | +``` |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## ✅ Pre-Deployment Checklist |
| 124 | + |
| 125 | +- [ ] All Python scripts run without errors |
| 126 | +- [ ] Tests pass (`pytest`) |
| 127 | +- [ ] Code is formatted (`black .`) |
| 128 | +- [ ] `vercel.json` is properly configured |
| 129 | +- [ ] API endpoints are tested locally |
| 130 | +- [ ] Environment variables are set (if needed) |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## 🎯 Post-Deployment |
| 135 | + |
| 136 | +After deploying to Vercel: |
| 137 | + |
| 138 | +1. Visit your deployed URL |
| 139 | +2. Test all API endpoints via the dashboard |
| 140 | +3. Share your deployment link! |
| 141 | + |
| 142 | +### Environment Variables (Optional) |
| 143 | + |
| 144 | +Set these in Vercel dashboard if needed: |
| 145 | + |
| 146 | +- `SECRET_KEY` - For API security |
| 147 | +- `DATABASE_URI` - For database connections |
| 148 | +- `JWT_SECRET_KEY` - For JWT authentication |
| 149 | + |
| 150 | +--- |
| 151 | + |
| 152 | +## 📞 Support |
| 153 | + |
| 154 | +For issues or questions: |
| 155 | +- Check the [README.md](./README.md) |
| 156 | +- Review [CONTRIBUTING.md](./CONTRIBUTING.md) |
| 157 | +- Open an issue on GitHub |
0 commit comments