RSCE / Dockerfile
LP1205's picture
Deploy RSCE backend to Hugging Face Space
5e952bb
Raw
History Blame Contribute Delete
1.14 kB
# Use a slim Python image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=.
# Set working directory
WORKDIR /app
# Install system dependencies needed for compiling python packages
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy pyproject.toml and source files
COPY pyproject.toml /app/
COPY README.md /app/
# Install dependencies
RUN pip install --upgrade pip && \
pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && \
pip install .
# Pre-download the DeBERTa-v3-large NLI cross-encoder at build time so cold
# starts don't re-fetch 1.6GB on the first request.
RUN python -c "from sentence_transformers import CrossEncoder; CrossEncoder('cross-encoder/nli-deberta-v3-large')"
# Copy the rest of the application
COPY . /app
# Seed the database with demo runs
RUN python scripts/seed_demo.py
# Expose backend port
EXPOSE 8000
# Start FastAPI server
CMD ["sh", "-c", "uvicorn api.app:app --host 0.0.0.0 --port ${PORT:-8000}"]