Knowledgebase / Dockerfile
abubasith86's picture
Update Dockerfile
5b43591 verified
# 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"]