File size: 1,467 Bytes
276a5e7 bc8608f 276a5e7 0e27589 276a5e7 0e27589 bc8608f 976eb67 bc8608f 0e27589 276a5e7 bc8608f 0e27589 976eb67 bc8608f 976eb67 0e27589 976eb67 ba4ee62 a3a48cf bc8608f 0e27589 276a5e7 ba4ee62 276a5e7 0e27589 ba4ee62 bc8608f 276a5e7 84b0fa3 |
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 53 54 55 56 |
# Use Python 3.11 slim image for Hugging Face Spaces
FROM python:3.11-slim
# Set environment variables for HF Spaces
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
HF_HOME=/app/.cache/huggingface \
TRANSFORMERS_CACHE=/app/.cache/transformers \
PORT=7860
# Set the working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Create cache directories
RUN mkdir -p /app/.cache/huggingface /app/.cache/transformers /app/logs
# Copy requirements first for better caching
COPY pyproject.toml ./
# Install Python dependencies
RUN pip install --upgrade pip setuptools wheel
RUN pip install --no-cache-dir -e .
# Copy the rest of the application code
COPY . .
# Create necessary directories and set permissions
RUN mkdir -p database logs && \
touch database/auth.db && \
chmod +x start_server.py && \
chmod -R 755 /app
# For HF Spaces compatibility, run as root (avoid permission issues)
# USER user
# Expose the port (HF Spaces default)
EXPOSE 7860
# Health check for HF Spaces monitoring
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Run the application with proper error handling
CMD ["python", "start_server.py"] |