-
Notifications
You must be signed in to change notification settings - Fork 0
286 lines (220 loc) · 8.27 KB
/
deploy.yml
File metadata and controls
286 lines (220 loc) · 8.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: 🚀 Deploy to Production
on:
push:
branches: [ main ]
tags: [ 'v*' ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# 🐳 Build Docker Images
build-images:
name: 🐳 Build Docker Images
runs-on: ubuntu-latest
outputs:
backend-image: ${{ steps.image-meta.outputs.backend-tags }}
frontend-image: ${{ steps.image-meta.outputs.frontend-tags }}
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 🔐 Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏷️ Extract Metadata
id: image-meta
run: |
echo "backend-tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend:${{ github.sha }}" >> $GITHUB_OUTPUT
echo "frontend-tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:${{ github.sha }}" >> $GITHUB_OUTPUT
- name: 🐳 Build Backend Docker Image
run: |
cat > backend/Dockerfile << 'EOF'
FROM python:3.11-slim
WORKDIR /app
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Copy uv files
COPY pyproject.toml uv.lock ./
# Install dependencies
RUN uv sync --frozen --no-dev
# Copy application code
COPY app/ ./app/
# Expose port
EXPOSE 8000
# Run application
CMD ["uv", "run", "python", "-m", "app.main"]
EOF
docker build -t ${{ steps.image-meta.outputs.backend-tags }} backend/
docker push ${{ steps.image-meta.outputs.backend-tags }}
- name: 🌐 Build Frontend Docker Image
run: |
cat > frontend/Dockerfile << 'EOF'
# Build stage
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build application
RUN npm run build
# Production stage
FROM node:18-alpine AS production
WORKDIR /app
# Copy built application
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
# Expose port
EXPOSE 3000
# Run application
CMD ["npm", "start"]
EOF
docker build -t ${{ steps.image-meta.outputs.frontend-tags }} frontend/
docker push ${{ steps.image-meta.outputs.frontend-tags }}
# 📋 Create Deployment Manifest
create-manifest:
name: 📋 Create Deployment Manifest
runs-on: ubuntu-latest
needs: build-images
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 📝 Generate Docker Compose
run: |
cat > docker-compose.prod.yml << EOF
version: '3.8'
services:
backend:
image: ${{ needs.build-images.outputs.backend-image }}
ports:
- "8000:8000"
environment:
- ENVIRONMENT=production
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
frontend:
image: ${{ needs.build-images.outputs.frontend-image }}
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- NEXT_PUBLIC_API_URL=http://localhost:8000
restart: unless-stopped
depends_on:
- backend
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
networks:
default:
driver: bridge
EOF
- name: 📤 Upload Docker Compose
uses: actions/upload-artifact@v4
with:
name: docker-compose-production
path: docker-compose.prod.yml
retention-days: 30
- name: 🚀 Generate Deployment Instructions
run: |
cat > DEPLOYMENT.md << EOF
# 🚀 Instructify Production Deployment
## Quick Start
\`\`\`bash
# Download the docker-compose file
curl -O https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/docker-compose.prod.yml
# Start the services
docker-compose -f docker-compose.prod.yml up -d
# Check status
docker-compose -f docker-compose.prod.yml ps
\`\`\`
## Access the Application
- 🌐 **Frontend**: http://localhost:3000
- 🔗 **Backend API**: http://localhost:8000
- 📊 **Health Check**: http://localhost:8000/health
## Environment Setup
Make sure you have Ollama running with Gemma 3 270M model:
\`\`\`bash
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Pull the model
ollama pull hf.co/unsloth/gemma-3-270m-it-GGUF:Q8_0
# Start Ollama server
ollama serve
\`\`\`
## Build Information
- 📅 **Build Date**: $(date)
- 🔖 **Commit**: ${{ github.sha }}
- 🌿 **Branch**: ${{ github.ref_name }}
- 👤 **Deployed by**: ${{ github.actor }}
- 🏷️ **Version**: ${{ github.ref_name }}
## Support
For issues and support, please visit: https://github.com/${{ github.repository }}/issues
EOF
- name: 📤 Upload Deployment Guide
uses: actions/upload-artifact@v4
with:
name: deployment-guide
path: DEPLOYMENT.md
retention-days: 90
# 📢 Create Release
create-release:
name: 📢 Create Release
runs-on: ubuntu-latest
needs: [build-images, create-manifest]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: 📤 Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: 🎉 Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
./artifacts/docker-compose-production/docker-compose.prod.yml
./artifacts/deployment-guide/DEPLOYMENT.md
body: |
# 🎓 Instructify Release ${{ github.ref_name }}
## 🚀 What's New
This release includes the latest features and improvements to the Instructify EdTech platform.
## 🐳 Docker Images
- **Backend**: `${{ needs.build-images.outputs.backend-image }}`
- **Frontend**: `${{ needs.build-images.outputs.frontend-image }}`
## 📦 Quick Deployment
```bash
# Download and start the application
curl -L -o docker-compose.prod.yml https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/docker-compose.prod.yml
docker-compose -f docker-compose.prod.yml up -d
```
## 🎯 Features
- ✅ AI-powered chat assistance with Gemma 3 270M
- ✅ Real-time video streaming with WebRTC
- ✅ Smart doubt classification system
- ✅ Live transcription and notes generation
- ✅ Modern Next.js 15 frontend with TypeScript
- ✅ FastAPI backend with WebSocket support
## 🔧 Requirements
- Docker & Docker Compose
- Ollama with Gemma 3 270M model
- 4GB+ RAM recommended
Full deployment guide included in the assets below! 📋
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}