Nada commited on
Commit
e1e64a5
·
1 Parent(s): 5e282d2
Files changed (2) hide show
  1. Dockerfile +14 -15
  2. chatbot.py +1 -4
Dockerfile CHANGED
@@ -1,8 +1,19 @@
1
  # Use Python 3.9 slim image
2
  FROM python:3.9-slim
3
 
 
 
 
 
 
 
 
 
 
4
  # Create a non-root user
5
- RUN useradd -m -s /bin/bash user
 
 
6
  USER user
7
  ENV HOME=/home/user \
8
  PATH=/home/user/.local/bin:$PATH
@@ -10,20 +21,8 @@ ENV HOME=/home/user \
10
  # Set working directory
11
  WORKDIR $HOME/app
12
 
13
- # Install system dependencies (need to switch to root temporarily)
14
- USER root
15
- RUN apt-get update && apt-get install -y \
16
- build-essential \
17
- && rm -rf /var/lib/apt/lists/*
18
-
19
- # Create necessary directories with proper permissions
20
- RUN mkdir -p /tmp/huggingface && \
21
- chmod -R 777 /tmp/huggingface && \
22
- mkdir -p $HOME/app/session_data $HOME/app/session_summaries $HOME/app/vector_db $HOME/app/models && \
23
- chown -R user:user $HOME/app
24
-
25
- # Switch back to non-root user
26
- USER user
27
 
28
  # Copy requirements first for better caching
29
  COPY --chown=user:user requirements.txt .
 
1
  # Use Python 3.9 slim image
2
  FROM python:3.9-slim
3
 
4
+ # Install system dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ build-essential \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # Create necessary directories and set permissions
10
+ RUN mkdir -p /tmp/huggingface && \
11
+ chmod -R 777 /tmp/huggingface
12
+
13
  # Create a non-root user
14
+ RUN useradd -m -s /bin/bash user && \
15
+ chown -R user:user /tmp/huggingface
16
+
17
  USER user
18
  ENV HOME=/home/user \
19
  PATH=/home/user/.local/bin:$PATH
 
21
  # Set working directory
22
  WORKDIR $HOME/app
23
 
24
+ # Create app directories
25
+ RUN mkdir -p $HOME/app/session_data $HOME/app/session_summaries $HOME/app/vector_db $HOME/app/models
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  # Copy requirements first for better caching
28
  COPY --chown=user:user requirements.txt .
chatbot.py CHANGED
@@ -72,11 +72,8 @@ def setup_cache_dirs():
72
  'BITSANDBYTES_NOWELCOME': '1'
73
  })
74
 
75
- # Create cache directory with proper permissions
76
  os.makedirs(cache_dir, exist_ok=True)
77
- if is_spaces:
78
- # Ensure directory is writable
79
- os.chmod(cache_dir, 0o777)
80
 
81
  return cache_dir
82
 
 
72
  'BITSANDBYTES_NOWELCOME': '1'
73
  })
74
 
75
+ # Create cache directory if it doesn't exist
76
  os.makedirs(cache_dir, exist_ok=True)
 
 
 
77
 
78
  return cache_dir
79