Final-text-classify / Dockerfile
Tantawi's picture
Upload 14 files
9d27b5e verified
# Use Python 3.10 slim image
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY symptom_checker.py .
COPY api_server.py .
# Copy model artifacts
COPY symptom_model.json .
COPY symptom_model.labels.npy .
COPY symptom_model.features.txt .
# Expose port (Hugging Face Spaces uses port 7860)
EXPOSE 7860
# Create a non-root user for security
RUN useradd -m -u 1000 appuser
USER appuser
# Run the FastAPI server
CMD ["uvicorn", "api_server:app", "--host", "0.0.0.0", "--port", "7860"]