Hasan-Atris3 commited on
Commit
18f36ed
·
1 Parent(s): 286d233

Add Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -9
Dockerfile CHANGED
@@ -22,19 +22,26 @@ RUN apt-get update && apt-get install -y \
22
  COPY requirements.txt .
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
25
- # 3. Download the Spacy model during build to save time on startup
26
  RUN python -m spacy download en_core_web_sm
27
 
28
- # 4. Copy the rest of the application code
29
- COPY . .
30
 
31
- # 5. Create the directory for the global DB if it doesn't exist
32
- RUN mkdir -p chroma_global_db
33
- RUN chmod -R 777 chroma_global_db
34
 
35
- # 6. Expose the port Chainlit runs on
 
 
 
 
 
 
 
 
 
36
  EXPOSE 7860
37
 
38
- # 7. Run the application
39
- # Chainlit on HuggingFace must run on port 7860
40
  CMD ["chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
 
22
  COPY requirements.txt .
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
25
+ # 3. Download the Spacy model during build
26
  RUN python -m spacy download en_core_web_sm
27
 
28
+ # 4. Create a non-root user (Required for Hugging Face)
29
+ RUN useradd -m -u 1000 user
30
 
31
+ # 5. Copy the rest of the application code & Fix Permissions
32
+ COPY --chown=user . .
 
33
 
34
+ # 6. Ensure the user can write to the DB directories
35
+ # We create the folder and give the user ownership
36
+ RUN mkdir -p chroma_global_db && chown -R user:user chroma_global_db
37
+ # We also ensure the /app directory is writable for the sqlite file
38
+ RUN chown -R user:user /app
39
+
40
+ # 7. Switch to the non-root user
41
+ USER user
42
+
43
+ # 8. Expose the port Chainlit runs on
44
  EXPOSE 7860
45
 
46
+ # 9. Run the application
 
47
  CMD ["chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]