Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +62 -0
Dockerfile
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Advanced Knowledge Base System - Hugging Face Space Dockerfile
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set environment variables
|
| 5 |
+
ENV PYTHONUNBUFFERED=1
|
| 6 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 7 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 8 |
+
ENV GRADIO_SERVER_PORT=7860
|
| 9 |
+
|
| 10 |
+
# Install system dependencies for document processing
|
| 11 |
+
RUN apt-get update && apt-get install -y \
|
| 12 |
+
git \
|
| 13 |
+
curl \
|
| 14 |
+
build-essential \
|
| 15 |
+
libssl-dev \
|
| 16 |
+
libffi-dev \
|
| 17 |
+
libxml2-dev \
|
| 18 |
+
libxslt1-dev \
|
| 19 |
+
zlib1g-dev \
|
| 20 |
+
libjpeg-dev \
|
| 21 |
+
libpng-dev \
|
| 22 |
+
poppler-utils \
|
| 23 |
+
tesseract-ocr \
|
| 24 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 25 |
+
|
| 26 |
+
# Create user for security (required by HF Spaces)
|
| 27 |
+
RUN useradd -m -u 1000 user
|
| 28 |
+
|
| 29 |
+
# Set working directory
|
| 30 |
+
WORKDIR /home/user/app
|
| 31 |
+
|
| 32 |
+
# Clone the repository (replace with your GitHub repo URL)
|
| 33 |
+
RUN git clone https://github.com/abubasith456/Knowledgebase.git . \
|
| 34 |
+
&& chown -R user:user /home/user/app
|
| 35 |
+
|
| 36 |
+
# Install Python dependencies from your existing requirements.txt
|
| 37 |
+
RUN pip install --no-cache-dir --upgrade pip \
|
| 38 |
+
&& pip install --no-cache-dir --upgrade -r requirements.txt
|
| 39 |
+
|
| 40 |
+
# Create necessary directories
|
| 41 |
+
RUN mkdir -p /home/user/app/chroma_db && chown -R user:user /home/user/app/chroma_db
|
| 42 |
+
|
| 43 |
+
# Switch to non-root user
|
| 44 |
+
USER user
|
| 45 |
+
|
| 46 |
+
# Set the home directory
|
| 47 |
+
ENV HOME=/home/user \
|
| 48 |
+
PATH=/home/user/.local/bin:$PATH
|
| 49 |
+
|
| 50 |
+
# Create user directories
|
| 51 |
+
RUN mkdir -p $HOME/.cache/huggingface \
|
| 52 |
+
&& mkdir -p $HOME/.cache/torch
|
| 53 |
+
|
| 54 |
+
# Expose the port
|
| 55 |
+
EXPOSE 7860
|
| 56 |
+
|
| 57 |
+
# Health check
|
| 58 |
+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
| 59 |
+
CMD curl -f http://localhost:7860/api/health || exit 1
|
| 60 |
+
|
| 61 |
+
# Run the application (adjust filename if different)
|
| 62 |
+
CMD ["python", "complete_advanced_kb_system.py"]
|