sagar008's picture
Update Dockerfile
4e4bd59 verified
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
wget \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
# Install dependencies with AGGRESSIVE plugin prevention
RUN pip install --no-cache-dir --upgrade pip
# STEP 1: Remove any existing pinecone packages and plugins
RUN pip uninstall pinecone pinecone-client pinecone-plugin-inference pinecone-plugin-records pinecone-plugin-assistant -y || true
# STEP 2: Clear pip cache to ensure clean install
RUN pip cache purge
# STEP 3: Install pinecone FIRST without any other packages
RUN pip install --no-cache-dir "pinecone>=3.0.0"
# STEP 4: Verify pinecone is installed correctly
RUN python -c "import pinecone; print(' Pinecone imported successfully')"
# STEP 5: Install remaining requirements
RUN pip install --no-cache-dir -r requirements.txt
# STEP 6: AGGRESSIVELY remove deprecated plugins that may have been pulled in
RUN pip uninstall pinecone-plugin-inference pinecone-plugin-records pinecone-plugin-assistant -y || true
# STEP 7: Final verification
RUN python -c "import pinecone; print(' Final pinecone check passed')" || \
(echo " Pinecone import failed - listing installed packages:" && pip list | grep pinecone)
# Create cache directories with proper permissions for HF Spaces
RUN mkdir -p /tmp/huggingface_cache /tmp/transformers_cache /tmp/sentence_transformers_cache /app/nltk_data
RUN chmod 777 /tmp/huggingface_cache /tmp/transformers_cache /tmp/sentence_transformers_cache
# Download NLTK data
RUN python -c "import nltk; nltk.download('punkt', download_dir='/app/nltk_data')" || true
# Copy application code
COPY . .
# Set cache environment variables for HF Spaces
ENV PYTHONPATH=/app
ENV NLTK_DATA=/app/nltk_data
ENV HF_HOME=/tmp/huggingface_cache
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/sentence_transformers_cache
ENV XDG_CACHE_HOME=/tmp
ENV TORCH_HOME=/tmp/torch_cache
EXPOSE 7860
CMD ["python", "main.py"]