tazwarrrr commited on
Commit
243b15a
·
1 Parent(s): 27c4e2c

fix front30

Browse files
Files changed (7) hide show
  1. .dockerignore +8 -0
  2. Dockerfile +8 -0
  3. backend/main.py +4 -2
  4. frontend/src/App.jsx +5 -1
  5. frontend/vite.config.js +10 -0
  6. start.bat +16 -3
  7. start.sh +16 -3
.dockerignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ .env
2
+ .venv/
3
+ venv/
4
+ __pycache__/
5
+ *.pyc
6
+ frontend/node_modules/
7
+ frontend/dist/
8
+ .git/
Dockerfile CHANGED
@@ -1,7 +1,15 @@
 
 
 
 
 
 
 
1
  FROM rocm/dev-ubuntu-22.04:latest
2
  WORKDIR /app
3
  COPY backend/requirements.txt .
4
  RUN pip install --no-cache-dir -r requirements.txt
5
  COPY . .
 
6
  EXPOSE 8000
7
  CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ FROM node:20-bookworm AS frontend-build
2
+ WORKDIR /app/frontend
3
+ COPY frontend/package*.json ./
4
+ RUN npm ci
5
+ COPY frontend/ ./
6
+ RUN npm run build
7
+
8
  FROM rocm/dev-ubuntu-22.04:latest
9
  WORKDIR /app
10
  COPY backend/requirements.txt .
11
  RUN pip install --no-cache-dir -r requirements.txt
12
  COPY . .
13
+ COPY --from=frontend-build /app/frontend/dist ./frontend/dist
14
  EXPOSE 8000
15
  CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
backend/main.py CHANGED
@@ -420,8 +420,10 @@ async def list_demo_kernels():
420
  return kernels
421
 
422
 
423
- # Serve frontend if built
424
- frontend_path = os.path.join(os.path.dirname(__file__), "..", "frontend")
 
 
425
  if os.path.exists(frontend_path):
426
  app.mount("/", StaticFiles(directory=frontend_path,
427
  html=True), name="frontend")
 
420
  return kernels
421
 
422
 
423
+ # Serve compiled frontend when available; fall back to the source folder for dev.
424
+ frontend_root = os.path.join(os.path.dirname(__file__), "..", "frontend")
425
+ frontend_dist = os.path.join(frontend_root, "dist")
426
+ frontend_path = frontend_dist if os.path.exists(frontend_dist) else frontend_root
427
  if os.path.exists(frontend_path):
428
  app.mount("/", StaticFiles(directory=frontend_path,
429
  html=True), name="frontend")
frontend/src/App.jsx CHANGED
@@ -1,5 +1,9 @@
1
  import { useState, useEffect, useRef } from 'react'
2
 
 
 
 
 
3
  // ─── Template Kernels ─────────────────────────────────────────────────────────
4
 
5
  const KERNEL_VECTOR_ADD = String.raw`
@@ -674,7 +678,7 @@ export default function App() {
674
  startTimer()
675
 
676
  try {
677
- const res = await fetch('http://localhost:8000/port', {
678
  method: 'POST',
679
  headers: { 'Content-Type': 'application/json' },
680
  body: JSON.stringify({
 
1
  import { useState, useEffect, useRef } from 'react'
2
 
3
+ const API_BASE = window.location.protocol === 'file:'
4
+ ? 'http://localhost:8000'
5
+ : window.location.origin
6
+
7
  // ─── Template Kernels ─────────────────────────────────────────────────────────
8
 
9
  const KERNEL_VECTOR_ADD = String.raw`
 
678
  startTimer()
679
 
680
  try {
681
+ const res = await fetch(`${API_BASE}/port`, {
682
  method: 'POST',
683
  headers: { 'Content-Type': 'application/json' },
684
  body: JSON.stringify({
frontend/vite.config.js CHANGED
@@ -5,5 +5,15 @@ export default defineConfig({
5
  plugins: [react()],
6
  server: {
7
  port: 5173,
 
 
 
 
 
 
 
 
 
 
8
  },
9
  })
 
5
  plugins: [react()],
6
  server: {
7
  port: 5173,
8
+ proxy: {
9
+ '/port': 'http://localhost:8000',
10
+ '/health': 'http://localhost:8000',
11
+ '/demo-kernels': 'http://localhost:8000',
12
+ '/benchmark-report': 'http://localhost:8000',
13
+ '/cold-start': 'http://localhost:8000',
14
+ '/aggregate-metric': 'http://localhost:8000',
15
+ '/recompile': 'http://localhost:8000',
16
+ '/export': 'http://localhost:8000',
17
+ },
18
  },
19
  })
start.bat CHANGED
@@ -2,10 +2,14 @@
2
  echo ROCmPort AI - Starting Backend Server...
3
  echo.
4
 
5
- cd /d "%~dp0backend"
6
 
7
  echo Installing dependencies...
8
- pip install -r requirements.txt
 
 
 
 
9
 
10
  echo.
11
  echo Setting up environment...
@@ -16,6 +20,15 @@ if not exist .env (
16
  echo.
17
  )
18
 
 
 
 
 
 
 
 
 
 
19
  echo.
20
  echo Starting FastAPI server...
21
  echo Server will be available at: http://localhost:8000
@@ -24,4 +37,4 @@ echo.
24
  echo Press Ctrl+C to stop the server
25
  echo.
26
 
27
- uvicorn main:app --reload --port 8000 --host 0.0.0.0
 
2
  echo ROCmPort AI - Starting Backend Server...
3
  echo.
4
 
5
+ cd /d "%~dp0"
6
 
7
  echo Installing dependencies...
8
+ if not exist .venv (
9
+ python -m venv .venv
10
+ )
11
+ call ".venv\Scripts\activate.bat"
12
+ pip install -r backend\requirements.txt
13
 
14
  echo.
15
  echo Setting up environment...
 
20
  echo.
21
  )
22
 
23
+ echo.
24
+ echo Building frontend...
25
+ npm --prefix frontend install
26
+ npm --prefix frontend run build
27
+ if errorlevel 1 (
28
+ echo Frontend build failed. Make sure Node.js and npm are installed.
29
+ exit /b 1
30
+ )
31
+
32
  echo.
33
  echo Starting FastAPI server...
34
  echo Server will be available at: http://localhost:8000
 
37
  echo Press Ctrl+C to stop the server
38
  echo.
39
 
40
+ python -m uvicorn backend.main:app --reload --port 8000 --host 0.0.0.0
start.sh CHANGED
@@ -3,10 +3,14 @@
3
  echo "ROCmPort AI - Starting Backend Server..."
4
  echo
5
 
6
- cd "$(dirname "$0")/backend"
7
 
8
  echo "Installing dependencies..."
9
- pip install -r requirements.txt
 
 
 
 
10
 
11
  echo
12
  echo "Setting up environment..."
@@ -17,6 +21,15 @@ if [ ! -f .env ]; then
17
  echo
18
  fi
19
 
 
 
 
 
 
 
 
 
 
20
  echo
21
  echo "Starting FastAPI server..."
22
  echo "Server will be available at: http://localhost:8000"
@@ -25,4 +38,4 @@ echo
25
  echo "Press Ctrl+C to stop the server"
26
  echo
27
 
28
- uvicorn main:app --reload --port 8000 --host 0.0.0.0
 
3
  echo "ROCmPort AI - Starting Backend Server..."
4
  echo
5
 
6
+ cd "$(dirname "$0")"
7
 
8
  echo "Installing dependencies..."
9
+ if [ ! -d .venv ]; then
10
+ python3 -m venv .venv
11
+ fi
12
+ . .venv/bin/activate
13
+ pip install -r backend/requirements.txt
14
 
15
  echo
16
  echo "Setting up environment..."
 
21
  echo
22
  fi
23
 
24
+ echo
25
+ echo "Building frontend..."
26
+ npm --prefix frontend install
27
+ npm --prefix frontend run build
28
+ if [ $? -ne 0 ]; then
29
+ echo "Frontend build failed. Make sure Node.js and npm are installed."
30
+ exit 1
31
+ fi
32
+
33
  echo
34
  echo "Starting FastAPI server..."
35
  echo "Server will be available at: http://localhost:8000"
 
38
  echo "Press Ctrl+C to stop the server"
39
  echo
40
 
41
+ python -m uvicorn backend.main:app --reload --port 8000 --host 0.0.0.0