File size: 2,054 Bytes
cf78558
c655ad7
 
 
 
 
 
 
 
 
 
c8669e0
c655ad7
c8669e0
7cf563d
c655ad7
7cf563d
 
 
 
 
 
 
 
 
 
 
4e4bd59
7cf563d
 
c655ad7
 
7cf563d
 
 
 
4e4bd59
 
7cf563d
96b5525
c13415f
 
6e5bb51
a4205a4
4e4bd59
c655ad7
 
 
 
96b5525
c655ad7
 
6e5bb51
 
c13415f
 
 
cf78558
c655ad7
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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"]