codeby-hp/sentiment-classification
0
1# Use Python 3.10 slim image for smaller size2FROM python:3.10-slim3 4# Set working directory5WORKDIR /app6 7# Install system dependencies8RUN apt-get update && apt-get install -y \9 build-essential \10 curl \11 && rm -rf /var/lib/apt/lists/*12 13# Copy requirements first for better layer caching14COPY requirements.txt .15 16# Install Python dependencies17RUN pip install --no-cache-dir -r requirements.txt18 19# Download NLTK data20RUN python -c "import nltk; nltk.download('stopwords'); nltk.download('wordnet'); nltk.download('omw-1.4')"21 22# Copy application files23COPY app.py .24COPY templates/ templates/25COPY models/ models/26 27# Expose port 7860 (Hugging Face Spaces default)28EXPOSE 786029 30# Set environment variables31ENV PYTHONUNBUFFERED=132ENV PORT=786033 34# Health check35HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \36 CMD curl -f http://localhost:7860/health || exit 137 38# Run the application39CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]40 