AE-Shree commited on
Commit
8e6cc5c
Β·
1 Parent(s): bda3c09

Deploy BioStack RLHF Medical Demo

Browse files
Files changed (2) hide show
  1. Dockerfile +22 -17
  2. server.py +6 -0
Dockerfile CHANGED
@@ -1,30 +1,35 @@
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 requirements first for better caching
13
- COPY requirements.txt .
14
- RUN pip install --no-cache-dir -r requirements.txt
15
-
16
- # Copy package files and install dependencies
17
  COPY package*.json ./
18
  RUN npm install
19
 
20
- # Copy all files
21
  COPY . .
22
-
23
- # Build React app
24
  RUN npm run build
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  # Expose port
27
  EXPOSE 7860
28
 
29
- # Run both frontend and backend
 
 
 
 
30
  CMD ["python", "server.py"]
 
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"]
server.py CHANGED
@@ -373,6 +373,12 @@ def reward_feedback(report: str, score: float) -> str:
373
  # ─────────────────────────────────────────────────────────────────────────────
374
  app = FastAPI(title="RLHF Medical Demo")
375
 
 
 
 
 
 
 
376
  app.add_middleware(
377
  CORSMiddleware,
378
  allow_origins=["*"],
 
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,
384
  allow_origins=["*"],