CoolFace
Apppublic

ArthyP/technical-rag-assistant

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
Dockerfile90 linesDownload Raw Back to root
1FROM python:3.11-slim2 3# Set working directory4WORKDIR /app5 6# Install system dependencies including Ollama requirements7RUN apt-get update && apt-get install -y \8    build-essential \9    curl \10    wget \11    software-properties-common \12    git \13    ca-certificates \14    gnupg \15    lsb-release \16    && rm -rf /var/lib/apt/lists/*17 18# Install Ollama19RUN curl -fsSL https://ollama.ai/install.sh | sh20 21# Copy requirements and install Python dependencies22COPY requirements.txt .23RUN pip install --no-cache-dir -r requirements.txt24 25# Copy application files26COPY . .27 28# Set Python path to include the app directory29ENV PYTHONPATH="/app:/app/src:$PYTHONPATH"30 31# Set HOME to app directory to avoid root directory writes32ENV HOME="/app"33ENV USER="appuser"34 35# Set Streamlit config directory to writable location36ENV STREAMLIT_CONFIG_DIR="/app/.streamlit"37 38# Disable Streamlit usage statistics to avoid permission issues39ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS="false"40 41# Set HuggingFace cache directory to writable location42ENV HF_HOME="/app/.cache"43ENV SENTENCE_TRANSFORMERS_HOME="/app/.cache/sentence-transformers"44 45# Download NLTK data if needed (for text processing)46RUN python -c "import nltk; nltk.download('punkt', quiet=True)" || true47 48# Pre-download the embedding model to avoid runtime permission issues49RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('sentence-transformers/multi-qa-MiniLM-L6-cos-v1'); print('Model downloaded successfully')" || echo "Model download failed, will retry at runtime"50 51# Create necessary directories with proper permissions52RUN mkdir -p .streamlit && \53    mkdir -p .cache && \54    mkdir -p .cache/transformers && \55    mkdir -p .cache/sentence-transformers && \56    mkdir -p temp_uploads && \57    chmod -R 777 .cache && \58    chmod 777 temp_uploads && \59    touch .gitconfig && \60    chmod 666 .gitconfig61 62# Expose Streamlit port63EXPOSE 850164 65# Health check for container monitoring66HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 167 68# Pre-pull the Ollama model during build (optional - for faster startup)69# RUN ollama serve & sleep 5 && ollama pull llama3.2:3b && pkill ollama70 71# Expose ports for both Streamlit and Ollama72EXPOSE 8501 1143473 74# Create directories with proper permissions for any user75RUN mkdir -p /app/.ollama && \76    mkdir -p /app/.ollama/models && \77    chmod -R 777 /app/.ollama78 79# Set Ollama environment variables to use app directory80ENV OLLAMA_MODELS=/app/.ollama/models81ENV OLLAMA_HOST=0.0.0.0:1143482 83# Ensure Ollama can write to its directories84RUN chmod -R 777 /app85 86# Create startup Python script87COPY startup.py /app/startup.py88 89# Run startup script that handles both Ollama and Streamlit90ENTRYPOINT ["python", "/app/startup.py"]