alaselababatunde commited on
Commit
fff75b8
·
1 Parent(s): dc80f34
Files changed (1) hide show
  1. Dockerfile +26 -14
Dockerfile CHANGED
@@ -1,31 +1,43 @@
1
- # ----------------------
2
- # DevAssist AI Dockerfile
3
- # ----------------------
4
-
5
- # Base image
6
  FROM python:3.10-slim
7
 
 
 
 
8
  # Set working directory
9
  WORKDIR /app
10
 
11
- # Create directories for caches and Chroma DB (writable by default user)
12
- RUN mkdir -p /app/huggingface_cache /app/Dev_Assist_SME_Builder_DB
 
 
 
13
 
14
- # Copy requirements first (to leverage Docker cache)
15
- COPY requirements.txt .
 
 
 
 
 
 
 
16
 
17
  # Install Python dependencies
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
- # Copy all project files
21
- COPY . .
 
 
 
22
 
23
  # Expose FastAPI port
24
  EXPOSE 7860
25
 
26
- # Set environment variables for cache directories (HuggingFace & Chroma)
27
  ENV HF_HOME=/app/huggingface_cache
28
- ENV CHROMA_DB_DIR=/app/Dev_Assist_SME_Builder_DB
29
 
30
- # Default command to start FastAPI via Uvicorn
31
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use lightweight Python image
 
 
 
 
2
  FROM python:3.10-slim
3
 
4
+ # Create a non-root user
5
+ RUN useradd -m appuser
6
+
7
  # Set working directory
8
  WORKDIR /app
9
 
10
+ # Give appuser ownership of /app
11
+ RUN chown -R appuser:appuser /app
12
+
13
+ # Switch to appuser
14
+ USER appuser
15
 
16
+ # Install system dependencies (needed for some models)
17
+ RUN apt-get update && apt-get install -y \
18
+ build-essential \
19
+ git \
20
+ curl \
21
+ && rm -rf /var/lib/apt/lists/*
22
+
23
+ # Copy requirements first for caching
24
+ COPY --chown=appuser:appuser requirements.txt .
25
 
26
  # Install Python dependencies
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
+ # Copy project files
30
+ COPY --chown=appuser:appuser . .
31
+
32
+ # Ensure HuggingFace cache directory exists and is writable
33
+ RUN mkdir -p /app/huggingface_cache && chmod -R 777 /app/huggingface_cache
34
 
35
  # Expose FastAPI port
36
  EXPOSE 7860
37
 
38
+ # Environment variables for HuggingFace
39
  ENV HF_HOME=/app/huggingface_cache
40
+ ENV TRANSFORMERS_CACHE=/app/huggingface_cache
41
 
42
+ # Run FastAPI
43
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]