Spaces:
Build error
Build error
File size: 1,439 Bytes
1ac9f32 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | FROM python:3.10-slim
# Install OS-level deps
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 🛡️ Sentinel: Ensure logs are streamed in real-time
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_DEFAULT_TIMEOUT=100
# Pre-create directories for static assets and models
RUN mkdir -p static models/sentiment uploads
# Update pip and install CPU-only deps
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir transformers
# Install requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create a dummy favicon if missing (stripped from HF push to avoid binary rejection)
RUN if [ ! -f static/favicon.png ]; then \
echo "" > static/favicon.png; \
fi
# Set up a non-root user required by Hugging Face
RUN adduser --system --uid 1000 --group user && \
chown -R 1000:1000 /app
USER 1000
# Pre-download the sentiment model (happens as the non-root user now)
ENV MODEL_DIR=/app/models/sentiment
RUN python scripts/download_model.py
# Expose port for Hugging Face Spaces
ENV PORT=7860
EXPOSE 7860
# Run with gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "300", "app:app"]
|