rafeeqxindus commited on
Commit
4a88a22
·
1 Parent(s): aeb5a9b

Create index directory

Browse files
Files changed (2) hide show
  1. Dockerfile +9 -12
  2. streamlit_app.py +2 -2
Dockerfile CHANGED
@@ -1,29 +1,26 @@
1
  # Use official lightweight Python image
2
  FROM python:3.10-slim
3
 
4
- RUN useradd -m -u 1000 user
5
- USER user
6
-
7
  # Set environment variables to disable usage stats collection (to prevent write errors)
8
  ENV STREAMLIT_BROWSER_GATHERUSAGESTATS=false
9
  ENV STREAMLIT_DISABLE_WATCHDOG_WARNINGS=true
10
  ENV STREAMLIT_SERVER_HEADLESS=true
11
  ENV STREAMLIT_SERVER_PORT=7860
12
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
13
- ENV HOME=/home/user
14
- ENV PATH="$PATH:/home/user/.local/bin"
15
 
16
  # Set working directory
17
- WORKDIR /home/user/app
 
 
 
18
 
19
  # Copy requirements and install
20
- COPY --chown=user ./requirements.txt requirements.txt
21
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
22
 
23
  # Copy the rest of the code
24
- COPY --chown=user . /home/user/app
25
-
26
- USER user
27
 
28
  # Run the app
29
- CMD ["streamlit", "run", "streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
1
  # Use official lightweight Python image
2
  FROM python:3.10-slim
3
 
 
 
 
4
  # Set environment variables to disable usage stats collection (to prevent write errors)
5
  ENV STREAMLIT_BROWSER_GATHERUSAGESTATS=false
6
  ENV STREAMLIT_DISABLE_WATCHDOG_WARNINGS=true
7
  ENV STREAMLIT_SERVER_HEADLESS=true
8
  ENV STREAMLIT_SERVER_PORT=7860
9
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
10
+ ENV HOME=/tmp
 
11
 
12
  # Set working directory
13
+ WORKDIR /app
14
+
15
+ # Create directory to store index with correct permissions
16
+ RUN mkdir -p /app/index && chmod -R 777 /app/index
17
 
18
  # Copy requirements and install
19
+ COPY requirements.txt .
20
+ RUN pip install --no-cache-dir -r requirements.txt
21
 
22
  # Copy the rest of the code
23
+ COPY . .
 
 
24
 
25
  # Run the app
26
+ CMD ["streamlit", "run", "streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
streamlit_app.py CHANGED
@@ -76,7 +76,7 @@ def get_text_chunks(text):
76
  def get_vector_store(text_chunks):
77
  embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
78
  vector_store = FAISS.from_texts(text_chunks, embedding=embeddings)
79
- vector_store.save_local("faiss_index")
80
 
81
  # ========================
82
  # 5️⃣ Conversational Chain Setup
@@ -100,7 +100,7 @@ def get_conversational_chain():
100
 
101
  def user_input(user_question):
102
  embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
103
- new_db = FAISS.load_local("faiss_index", embeddings, allow_dangerous_deserialization=True)
104
  docs = new_db.similarity_search(user_question)
105
 
106
 
 
76
  def get_vector_store(text_chunks):
77
  embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
78
  vector_store = FAISS.from_texts(text_chunks, embedding=embeddings)
79
+ vector_store.save_local("/app/index/faiss_index")
80
 
81
  # ========================
82
  # 5️⃣ Conversational Chain Setup
 
100
 
101
  def user_input(user_question):
102
  embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
103
+ new_db = FAISS.load_local("/app/index/faiss_index", embeddings, allow_dangerous_deserialization=True)
104
  docs = new_db.similarity_search(user_question)
105
 
106