dosemate / Dockerfile
DoseMate
Deploy DoseMate to Hugging Face Spaces
a0c836f
Raw History Blame Contribute Delete
1.19 kB
# 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"]