AreejMehboob commited on
Commit
a80cc1e
·
verified ·
1 Parent(s): 5eef819

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -5
Dockerfile CHANGED
@@ -15,18 +15,37 @@ RUN apt-get update && apt-get install -y \
15
  git \
16
  && rm -rf /var/lib/apt/lists/*
17
 
 
 
 
18
  # Create necessary directories with proper permissions
19
  RUN mkdir -p /app/.cache/huggingface/transformers \
20
  && mkdir -p /app/.streamlit \
21
- && chmod -R 777 /app
 
22
 
23
- # Copy files
24
  COPY requirements.txt ./
25
  COPY src/ ./src/
26
 
27
  # Install Python dependencies
28
  RUN pip install --no-cache-dir -r requirements.txt
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  # Expose Streamlit's default port
31
  EXPOSE 8501
32
 
@@ -34,6 +53,4 @@ EXPOSE 8501
34
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
35
 
36
  # Start the Streamlit app
37
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py","--server.enableXsrfProtection=false","--server.port=8501", "--server.address=0.0.0.0"]
38
-
39
-
 
15
  git \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
+ # Create app user and group for better security
19
+ RUN groupadd -r appuser && useradd -r -g appuser appuser
20
+
21
  # Create necessary directories with proper permissions
22
  RUN mkdir -p /app/.cache/huggingface/transformers \
23
  && mkdir -p /app/.streamlit \
24
+ && mkdir -p /app/temp \
25
+ && mkdir -p /app/src
26
 
27
+ # Copy files first
28
  COPY requirements.txt ./
29
  COPY src/ ./src/
30
 
31
  # Install Python dependencies
32
  RUN pip install --no-cache-dir -r requirements.txt
33
 
34
+ # Fix permissions for Qdrant database directory
35
+ # This is the key fix for your issue
36
+ RUN if [ -d "/app/src/qdrant_data_tesla" ]; then \
37
+ chmod -R 755 /app/src/qdrant_data_tesla && \
38
+ find /app/src/qdrant_data_tesla -type f -exec chmod 644 {} \; && \
39
+ find /app/src/qdrant_data_tesla -type d -exec chmod 755 {} \; && \
40
+ rm -f /app/src/qdrant_data_tesla/.lock; \
41
+ fi
42
+
43
+ # Change ownership of the entire app directory to appuser
44
+ RUN chown -R appuser:appuser /app
45
+
46
+ # Switch to non-root user
47
+ USER appuser
48
+
49
  # Expose Streamlit's default port
50
  EXPOSE 8501
51
 
 
53
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
54
 
55
  # Start the Streamlit app
56
+ ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.enableXsrfProtection=false", "--server.port=8501", "--server.address=0.0.0.0"]