Soumik Bose commited on
Commit
5aaa926
·
1 Parent(s): a2e3298
Files changed (1) hide show
  1. Dockerfile +21 -10
Dockerfile CHANGED
@@ -8,28 +8,39 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
8
 
9
  WORKDIR /app
10
 
11
- # Create user
 
 
 
 
 
 
12
  RUN useradd -m -u 1000 user
13
- RUN mkdir -p /app/cache /app/models && chown -R user:user /app
14
 
15
- # Install pip as root
16
  RUN pip install --no-cache-dir --upgrade pip
17
 
18
  USER user
19
 
20
- # 1. Copy the wheels folder into the image
 
21
  COPY --chown=user:user ./wheels /app/wheels
22
 
23
- # 2. Install the wheel directly (Wildcard * handles version changes automatically)
24
- # We don't need CMAKE_ARGS here because the wheel is already compiled!
25
  RUN pip install --no-cache-dir /app/wheels/llama_cpp_python-*.whl
26
 
27
- # 3. Install other dependencies (numpy, uvicorn, etc.)
28
  COPY --chown=user:user requirements.txt .
29
  RUN pip install --no-cache-dir -r requirements.txt
30
 
31
- # Copy app code
32
- COPY --chown=user:user main.py .
 
 
33
 
34
  EXPOSE 7860
35
- CMD ["bash", "-c", "while true; do curl -s https://xce009-ai-chat-api.hf.space/ping > /dev/null || true; sleep 300; done & python -m uvicorn main:app --host 0.0.0.0 --port 7860"]
 
 
 
8
 
9
  WORKDIR /app
10
 
11
+ # 1. Install only runtime dependencies (curl for healthchecks)
12
+ # REMOVED: build-essential, cmake, git (Not needed anymore!)
13
+ RUN apt-get update && apt-get install -y \
14
+ curl \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ # 2. Create user and directories
18
  RUN useradd -m -u 1000 user
19
+ RUN mkdir -p /app/cache /app/models /app/wheels && chown -R user:user /app
20
 
21
+ # 3. Install pip
22
  RUN pip install --no-cache-dir --upgrade pip
23
 
24
  USER user
25
 
26
+ # 4. Install the Local Wheel
27
+ # This copies your local 'wheels' folder into the Docker image
28
  COPY --chown=user:user ./wheels /app/wheels
29
 
30
+ # This installs the pre-built wheel.
31
+ # We REMOVED CMAKE_ARGS because the wheel is already compiled!
32
  RUN pip install --no-cache-dir /app/wheels/llama_cpp_python-*.whl
33
 
34
+ # 5. Install other dependencies (FastAPI, uvicorn, etc.)
35
  COPY --chown=user:user requirements.txt .
36
  RUN pip install --no-cache-dir -r requirements.txt
37
 
38
+ # 6. Copy ALL Application Code
39
+ # Using "COPY . ." is safer than listing files manually because
40
+ # it ensures config.py, services/, routers/, and utils/ are all included.
41
+ COPY --chown=user:user . .
42
 
43
  EXPOSE 7860
44
+
45
+ # 7. Start the app (With keep-alive loop for Hugging Face Spaces)
46
+ CMD ["bash", "-c", "while true; do curl -s http://localhost:7860/health > /dev/null || true; sleep 300; done & python -m uvicorn main:app --host 0.0.0.0 --port 7860"]