Soumik Bose commited on
Commit
084ea47
·
1 Parent(s): 29aca70
Files changed (3) hide show
  1. Dockerfile +6 -17
  2. README.md +2 -0
  3. requirements.txt +5 -0
Dockerfile CHANGED
@@ -1,6 +1,5 @@
1
- FROM python:3.11-slim
2
 
3
- # Set environment variables
4
  ENV PYTHONDONTWRITEBYTECODE=1 \
5
  PYTHONUNBUFFERED=1 \
6
  PORT=7860 \
@@ -8,34 +7,24 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
8
 
9
  WORKDIR /app
10
 
11
- # Install system dependencies including build tools
12
  RUN apt-get update && apt-get install -y \
13
- build-essential \
14
- cmake \
15
  curl \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
- # Create non-root user (Required for HF Spaces)
19
  RUN useradd -m -u 1000 user
20
  RUN mkdir -p /app/cache /app/models && chown -R user:user /app
21
 
22
- # Upgrade pip (as root before switching users)
23
- RUN pip install --no-cache-dir --upgrade pip
24
-
25
- # Switch to user
26
  USER user
27
 
28
- # Install llama-cpp-python with pre-built wheel
29
- RUN pip install --no-cache-dir llama-cpp-python \
30
- --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
31
-
32
- # Install the rest of the requirements
33
  COPY --chown=user:user requirements.txt .
34
  RUN pip install --no-cache-dir -r requirements.txt
35
 
36
- # Copy app code
37
  COPY --chown=user:user main.py .
38
 
39
- # Run
40
  EXPOSE 7860
41
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.10-slim
2
 
 
3
  ENV PYTHONDONTWRITEBYTECODE=1 \
4
  PYTHONUNBUFFERED=1 \
5
  PORT=7860 \
 
7
 
8
  WORKDIR /app
9
 
10
+ # Minimal system dependencies
11
  RUN apt-get update && apt-get install -y \
 
 
12
  curl \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Create non-root user (required for HF Spaces)
16
  RUN useradd -m -u 1000 user
17
  RUN mkdir -p /app/cache /app/models && chown -R user:user /app
18
 
 
 
 
 
19
  USER user
20
 
21
+ # Install dependencies
22
+ RUN pip install --no-cache-dir --upgrade pip
 
 
 
23
  COPY --chown=user:user requirements.txt .
24
  RUN pip install --no-cache-dir -r requirements.txt
25
 
26
+ # Copy app
27
  COPY --chown=user:user main.py .
28
 
 
29
  EXPOSE 7860
30
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -6,4 +6,6 @@ colorTo: pink
6
  sdk: docker
7
  app_file: main.py
8
  pinned: false
 
 
9
  ---
 
6
  sdk: docker
7
  app_file: main.py
8
  pinned: false
9
+ python_version: "3.10"
10
+ startup_duration_timeout: 1h
11
  ---
requirements.txt CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  fastapi>=0.115.0
2
  uvicorn>=0.30.0
3
  pydantic>=2.8.0
 
1
+ --prefer-binary
2
+ --only-binary llama-cpp-python
3
+ --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
4
+
5
+ llama-cpp-python>=0.2.90
6
  fastapi>=0.115.0
7
  uvicorn>=0.30.0
8
  pydantic>=2.8.0