AE-Shree commited on
Commit
83e9d59
Β·
1 Parent(s): c7c6957

Deploy BioStack RLHF Medical Demo

Browse files
Files changed (2) hide show
  1. Dockerfile +13 -19
  2. server.py +6 -2
Dockerfile CHANGED
@@ -1,35 +1,29 @@
1
- FROM node:20-slim AS frontend-builder
 
 
 
 
 
 
2
 
3
- # Set working directory for frontend
4
  WORKDIR /app
5
 
6
- # Copy package files first for better caching
7
  COPY package*.json ./
8
  RUN npm install
9
 
10
- # Copy React source and build
11
  COPY . .
12
- RUN npm run build
13
-
14
- # Production stage with Python
15
- FROM python:3.11-slim
16
 
17
- # Copy built React app from frontend-builder
18
- COPY --from=frontend-builder /app/build /app/build
19
 
20
- # Copy Python requirements and install
21
- COPY requirements.txt .
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
24
- # Copy Python source code
25
- COPY server.py ./
26
-
27
  # Expose port
28
  EXPOSE 7860
29
 
30
- # Health check
31
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
32
- CMD curl -f http://localhost:7860/health || exit 1
33
-
34
  # Run the application
35
  CMD ["python", "server.py"]
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install Node.js for building React app
4
+ RUN apt-get update && apt-get install -y \
5
+ nodejs \
6
+ npm \
7
+ && rm -rf /var/lib/apt/lists/*
8
 
9
+ # Set working directory
10
  WORKDIR /app
11
 
12
+ # Copy package files and install Node dependencies
13
  COPY package*.json ./
14
  RUN npm install
15
 
16
+ # Copy all source files
17
  COPY . .
 
 
 
 
18
 
19
+ # Build React app
20
+ RUN npm run build
21
 
22
+ # Install Python dependencies
 
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
 
 
 
25
  # Expose port
26
  EXPOSE 7860
27
 
 
 
 
 
28
  # Run the application
29
  CMD ["python", "server.py"]
server.py CHANGED
@@ -373,11 +373,15 @@ def reward_feedback(report: str, score: float) -> str:
373
  # ─────────────────────────────────────────────────────────────────────────────
374
  app = FastAPI(title="RLHF Medical Demo")
375
 
376
-
377
  # Mount static files for React app (must come before CORS and routes)
378
  from fastapi.staticfiles import StaticFiles
379
- app.mount("/", StaticFiles(directory="build", html=True), name="static")
380
 
 
 
 
 
 
381
 
382
  app.add_middleware(
383
  CORSMiddleware,
 
373
  # ─────────────────────────────────────────────────────────────────────────────
374
  app = FastAPI(title="RLHF Medical Demo")
375
 
 
376
  # Mount static files for React app (must come before CORS and routes)
377
  from fastapi.staticfiles import StaticFiles
378
+ import os
379
 
380
+ # Check if build directory exists, create fallback if needed
381
+ if os.path.exists("build"):
382
+ app.mount("/", StaticFiles(directory="build", html=True), name="static")
383
+ else:
384
+ print("WARNING: Build directory not found, serving API only")
385
 
386
  app.add_middleware(
387
  CORSMiddleware,