Kalpokoch commited on
Commit
28a782e
·
verified ·
1 Parent(s): b98ca48

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -19
Dockerfile CHANGED
@@ -1,39 +1,39 @@
1
- # Use official Python 3.11 base image
2
- FROM python:3.11
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
 
6
  build-essential \
7
- cmake \
8
- git \
9
- curl \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  # Set working directory
13
  WORKDIR /app
14
 
15
- # Download the quantized GGUF model from Hugging Face
16
- RUN curl -L -o /app/tinyllama_dop_q4_k_m.gguf \
17
- https://huggingface.co/Kalpokoch/FinetunedQuantizedTinyLama/resolve/main/tinyllama_dop_q4_k_m.gguf
18
-
19
- # Set Hugging Face and ChromaDB cache directories
20
  ENV TRANSFORMERS_CACHE=/app/.cache \
21
  HF_HOME=/app/.cache \
22
- PYTHONUNBUFFERED=1 \
23
- PERSIST_DIR=/app/vector_database
 
 
24
 
25
- RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
26
- RUN mkdir -p ${PERSIST_DIR} && chmod -R 777 ${PERSIST_DIR}
 
27
 
28
- # Install Python dependencies
29
  COPY requirements.txt .
30
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
31
 
32
- # Copy project code
33
  COPY . .
34
 
35
- # Expose the port FastAPI will run on
36
  EXPOSE 7860
37
 
38
- # Run the FastAPI app using uvicorn
39
  CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use official Python image with basic system utilities
2
+ FROM python:3.11-slim
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
6
+ wget \
7
  build-essential \
 
 
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Set working directory
11
  WORKDIR /app
12
 
13
+ # Set HF cache dir for transformers, chromadb, etc.
 
 
 
 
14
  ENV TRANSFORMERS_CACHE=/app/.cache \
15
  HF_HOME=/app/.cache \
16
+ PIP_NO_CACHE_DIR=true
17
+
18
+ # Create required dirs with open permissions
19
+ RUN mkdir -p /app/.cache /app/vector_database && chmod -R 777 /app/.cache /app/vector_database
20
 
21
+ # Pre-download your quantized GGUF model from HF
22
+ # (Replace with your exact file path if different)
23
+ RUN wget https://huggingface.co/Kalpokoch/FinetunedQuantizedTinyLama/resolve/main/tinyllama_dop_q4_k_m.gguf -O /app/tinyllama_dop_q4_k_m.gguf
24
 
25
+ # Install Python dependencies separately to leverage Docker caching
26
  COPY requirements.txt .
27
+ RUN pip install -r requirements.txt
28
+
29
+ # Install llama-cpp-python from wheel (avoid compilation)
30
+ RUN pip install llama-cpp-python --prefer-binary
31
 
32
+ # Copy the app code
33
  COPY . .
34
 
35
+ # Expose port for FastAPI
36
  EXPOSE 7860
37
 
38
+ # Launch app
39
  CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"]