File size: 1,541 Bytes
9dfc96d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# # 1. Start with an OS that already has CUDA and PyTorch installed
# FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime

# # 2. Set the working directory inside the container
# WORKDIR /app

# # 3. Copy your requirements file and install dependencies
# # (You will need to create a requirements.txt with fastapi, uvicorn, transformers, bitsandbytes, faiss-cpu, sentence-transformers, etc.)
# COPY requirements.txt .
# RUN pip install --no-cache-dir -r requirements.txt

# # 4. Copy your actual code and knowledge base into the container
# COPY . .

# # 5. Open port 8000 so the outside world can talk to the API
# EXPOSE 8000

# # 6. Start the FastAPI server when the container boots
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]




# 1. Use a lightweight Python base
FROM python:3.11-slim

# 2. Install system dependencies for building llama-cpp on a CPU
RUN apt-get update && apt-get install -y \
    build-essential \
    cmake \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

# 3. Set up a non-root user (Strict Hugging Face Security Requirement)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

# 4. Install your Python dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# 5. Copy your actual code and knowledge base into the container
COPY --chown=user . .

# 6. Run the app using Python so it triggers the dynamic port logic in app.py
CMD ["python", "app.py"]