File size: 1,644 Bytes
c157bf8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b43591
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
57
58
59
60
61
62
63
# Advanced Knowledge Base System - Hugging Face Space Dockerfile
FROM python:3.10-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV GRADIO_SERVER_PORT=7860

# Install system dependencies for document processing
RUN apt-get update && apt-get install -y \
    git \
    curl \
    build-essential \
    libssl-dev \
    libffi-dev \
    libxml2-dev \
    libxslt1-dev \
    zlib1g-dev \
    libjpeg-dev \
    libpng-dev \
    poppler-utils \
    tesseract-ocr \
    && rm -rf /var/lib/apt/lists/*

# Create user for security (required by HF Spaces)
RUN useradd -m -u 1000 user

# Set working directory
WORKDIR /home/user/app

# Clone the repository (replace with your GitHub repo URL)
RUN git clone https://github.com/abubasith456/Knowledgebase.git . \
    && chown -R user:user /home/user/app

# Install Python dependencies from your existing requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir --upgrade -r requirements.txt

# Create necessary directories
RUN mkdir -p /home/user/app/chroma_db && chown -R user:user /home/user/app/chroma_db

# Switch to non-root user
USER user

# Set the home directory
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Create user directories
RUN mkdir -p $HOME/.cache/huggingface \
    && mkdir -p $HOME/.cache/torch

# Expose the port
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:7860/api/health || exit 1

# Run the application (adjust filename if different)
CMD ["python", "main.py"]