File size: 1,194 Bytes
a0c836f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# DoseMate — single-image deploy (API + built frontend) for Hugging Face Spaces.
# Stage 1 builds the React frontend; stage 2 runs FastAPI and serves it.

# ---------- Stage 1: build the frontend ----------
FROM node:20-slim AS frontend
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build

# ---------- Stage 2: python runtime ----------
FROM python:3.11-slim

ENV PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    HF_HOME=/app/.cache \
    DATABASE_URL=sqlite:///./pharmachat.db

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
    && rm -rf /var/lib/apt/lists/*

# Python deps (heavy: torch / chromadb / sentence-transformers)
COPY requirements.txt ./
RUN pip install -r requirements.txt

# App code
COPY *.py ./
COPY routers/ ./routers/
COPY medicines.json ./

# Built frontend from stage 1
COPY --from=frontend /app/frontend/dist ./frontend/dist

# Build the vector store at image-build time (no API keys needed for this step)
RUN python build_chroma.py

# HF Spaces expects the app on port 7860
EXPOSE 7860
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]