finner / Dockerfile
bkalyankrishnareddy
Fix: set PORT=7860 for HuggingFace Spaces
0796851
Raw
History Blame Contribute Delete
1.17 kB
# Production image — CPU-only inference, no training deps.
# The fine-tuned encoder (~110M params) runs at ~tens of ms/sentence on CPU.
FROM python:3.12-slim
WORKDIR /app
# CPU-only torch must be installed before other packages to prevent pip
# from pulling in the full CUDA wheel via the default PyPI index.
RUN pip install --no-cache-dir \
torch torchvision \
--index-url https://download.pytorch.org/whl/cpu
# Inference-only deps (no training/eval packages)
RUN pip install --no-cache-dir \
"transformers>=4.40" \
"fastapi>=0.110" \
"uvicorn[standard]>=0.29" \
"pydantic>=2.0" \
"pydantic-settings>=2.0" \
python-dotenv \
httpx \
rich \
numpy
COPY src/ ./src/
COPY checkpoints/best/ ./checkpoints/best/
COPY frontend/ ./frontend/
# Copy results artifacts (summary.json + PNGs for dashboard).
# /metrics returns 404 gracefully if summary.json is absent.
COPY results/ ./results/
ENV PYTHONPATH=/app/src
# PORT is set to 7860 by HuggingFace Spaces; defaults to 8000 for local Docker.
ENV PORT=7860
EXPOSE 7860
EXPOSE 8000
CMD ["sh", "-c", "uvicorn finner.api.app:app --host 0.0.0.0 --port ${PORT} --workers 1"]