AE-Shree commited on
Commit Β·
83e9d59
1
Parent(s): c7c6957
Deploy BioStack RLHF Medical Demo
Browse files- Dockerfile +13 -19
- server.py +6 -2
Dockerfile
CHANGED
|
@@ -1,35 +1,29 @@
|
|
| 1 |
-
FROM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Copy package files
|
| 7 |
COPY package*.json ./
|
| 8 |
RUN npm install
|
| 9 |
|
| 10 |
-
# Copy
|
| 11 |
COPY . .
|
| 12 |
-
RUN npm run build
|
| 13 |
-
|
| 14 |
-
# Production stage with Python
|
| 15 |
-
FROM python:3.11-slim
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
|
| 20 |
-
#
|
| 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 |
-
|
| 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,
|