Spaces:
Sleeping
Sleeping
Remove Docker artifacts from Gradio ZeroGPU Space
Browse filesFiles changed (3)
- DockerfileDeleted-68
- Dockerfile.appDeleted-80
- docker-compose.ymlDeleted-91
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768# Dockerfile for HuggingFace Spaces with Ollama supportFROM python:3.11-slim
# Set working directoryWORKDIR /app
# Install system dependenciesRUN apt-get update && apt-get install -y \ curl \ build-essential \ zstd \ && rm -rf /var/lib/apt/lists/*
# Install OllamaRUN curl -fsSL https://ollama.ai/install.sh | sh
# Copy requirementsCOPY requirements.txt .
# Install CPU-only PyTorch first (saves ~2GB by avoiding CUDA dependencies)RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
# Install Python dependenciesRUN pip install --no-cache-dir -r requirements.txt
# Copy application filesCOPY . .
# Create necessary directoriesRUN mkdir -p data/documents chroma_db bm25_index
# Expose Streamlit portEXPOSE 7860
# Expose Ollama portEXPOSE 11434
# Start script that runs both Ollama and StreamlitCOPY <<'EOF' /app/start.sh#!/bin/bashset -e
# Start Ollama in the backgroundollama serve &OLLAMA_PID=$!
# Wait for Ollama to be readyecho "Waiting for Ollama to start..."sleep 5
# Pull the model (use small model for HF Spaces)MODEL=${OLLAMA_MODEL:-llama3.2:3b}echo "Pulling model: $MODEL"ollama pull $MODEL || echo "Model pull failed, will retry on app start"
# Build retrieval indexes if documents exist and indexes don'tif [ -d "data/documents" ] && [ ! -f "chroma_db/chroma.sqlite3" ]; then echo "Building retrieval indexes (BM25 + Vector)..." python -m src.build_vectorstore || echo "Index build failed, will build on first use"fi
# Start Streamlitstreamlit run app.py --server.port=7860 --server.address=0.0.0.0EOF
RUN chmod +x /app/start.sh
CMD ["/app/start.sh"]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980# Dockerfile for Streamlit RAG Application (for Docker Compose)# Use with docker-compose.yml - Ollama runs as a separate serviceFROM python:3.11-slim
# Set working directoryWORKDIR /app
# Install system dependenciesRUN apt-get update && apt-get install -y \ curl \ build-essential \ zstd \ && rm -rf /var/lib/apt/lists/*
# Copy requirementsCOPY requirements.txt .
# Install CPU-only PyTorch first (saves ~2GB by avoiding CUDA dependencies)RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
# Install Python dependenciesRUN pip install --no-cache-dir -r requirements.txt
# Copy application filesCOPY src/ ./src/COPY app.py .COPY config.yaml .COPY .streamlit/ ./.streamlit/
# Create necessary directoriesRUN mkdir -p data/documents chroma_db bm25_index
# Create startup scriptCOPY <<'EOF' /app/start.sh#!/bin/bashset -e
echo "Starting ProfillyBot Application..."
# Wait for Ollama to be available (if using Ollama)if [ -n "$OLLAMA_HOST" ]; then echo "Waiting for Ollama at $OLLAMA_HOST..." for i in {1..30}; do if curl -sf "$OLLAMA_HOST/api/tags" > /dev/null 2>&1; then echo "Ollama is ready!" break fi echo "Waiting for Ollama... ($i/30)" sleep 2 donefi
# Build retrieval indexes if documents exist and indexes don'tif [ -d "data/documents" ] && [ "$(ls -A data/documents 2>/dev/null)" ]; then if [ ! -f "chroma_db/chroma.sqlite3" ]; then echo "Building retrieval indexes (BM25 + Vector)..." python -m src.build_vectorstore || echo "Index build failed, will build on first use" else echo "Indexes already exist, skipping build" fifi
# Start Streamlitecho "Starting Streamlit on port ${STREAMLIT_SERVER_PORT:-7860}..."exec streamlit run app.py \ --server.port=${STREAMLIT_SERVER_PORT:-7860} \ --server.address=${STREAMLIT_SERVER_ADDRESS:-0.0.0.0} \ --server.headless=trueEOF
RUN chmod +x /app/start.sh
# Expose Streamlit portEXPOSE 7860
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ CMD curl -f http://localhost:7860/_stcore/health || exit 1
CMD ["/app/start.sh"]12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091version: "3.8"
services: # Ollama LLM Service ollama: image: ollama/ollama:latest container_name: profillybot-ollama restart: unless-stopped ports: - "11434:11434" volumes: - ollama_data:/root/.ollama environment: - OLLAMA_HOST=0.0.0.0 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:11434/api/tags"] interval: 30s timeout: 10s retries: 5 start_period: 10s deploy: resources: limits: memory: 8G reservations: memory: 4G
# Model Initialization (pulls the model on first run) ollama-pull: image: ollama/ollama:latest container_name: profillybot-ollama-pull depends_on: ollama: condition: service_healthy environment: - OLLAMA_HOST=ollama - OLLAMA_MODEL=${OLLAMA_MODEL:-llama3.2:3b} entrypoint: ["/bin/sh", "-c"] command: - | echo "Pulling model: $${OLLAMA_MODEL}..." ollama pull $${OLLAMA_MODEL} echo "Model pulled successfully!" restart: "no"
# Streamlit RAG Application app: build: context: . dockerfile: Dockerfile.app container_name: profillybot-app restart: unless-stopped ports: - "7860:7860" volumes: - ./data/documents:/app/data/documents:ro - chroma_db:/app/chroma_db - bm25_index:/app/bm25_index - ./config.yaml:/app/config.yaml:ro environment: # Ollama configuration (uses the ollama service) - OLLAMA_HOST=http://ollama:11434 - OLLAMA_MODEL=${OLLAMA_MODEL:-llama3.2:3b} # Optional: Groq API for cloud LLM (comment out OLLAMA vars to use) - GROQ_API_KEY=${GROQ_API_KEY:-} # Streamlit settings - STREAMLIT_SERVER_PORT=7860 - STREAMLIT_SERVER_ADDRESS=0.0.0.0 - STREAMLIT_SERVER_HEADLESS=true - STREAMLIT_BROWSER_GATHER_USAGE_STATS=false depends_on: ollama: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:7860/_stcore/health"] interval: 30s timeout: 10s retries: 5 start_period: 30s
volumes: ollama_data: name: profillybot-ollama-data chroma_db: name: profillybot-chroma-db bm25_index: name: profillybot-bm25-index
networks: default: name: profillybot-networkDockerfileDeleted-68
Dockerfile.appDeleted-80
docker-compose.ymlDeleted-91