AnatoliiG commited on
Commit
0fb3706
·
1 Parent(s): 30c91aa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -10
Dockerfile CHANGED
@@ -1,15 +1,34 @@
1
- # Используем Python 3.10 (Debian-based)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  FROM python:3.10-slim
3
 
4
- # Настройки окружения
 
 
5
  ENV PYTHONUNBUFFERED=1 \
6
  HF_HOME=/home/user/cache \
7
  HOME=/home/user \
8
  PATH=/home/user/.local/bin:$PATH
9
 
10
- WORKDIR /app
11
-
12
- # Устанавливаем системные зависимости
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  curl \
15
  libgomp1 \
@@ -20,14 +39,13 @@ RUN useradd -m -u 1000 user
20
  USER user
21
  RUN mkdir -p $HF_HOME
22
 
 
 
23
  COPY --chown=user requirements.txt requirements.txt
24
  RUN pip install --no-cache-dir --upgrade pip && \
25
- pip install --no-cache-dir -r requirements.txt
26
-
27
- RUN pip install --no-cache-dir \
28
- https://github.com/abetlen/llama-cpp-python/releases/download/v0.3.1/llama_cpp_python-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
29
 
30
- # Копируем код
31
  COPY --chown=user app.py app.py
32
 
33
  EXPOSE 7860
 
1
+ # --- ЭТАП 1: Сборщик (Builder) ---
2
+ # Используем тот же образ, что и в финале, чтобы версии библиотек совпадали
3
+ FROM python:3.10-slim as builder
4
+
5
+ # Отключаем буферизацию и лишние файлы
6
+ ENV PYTHONUNBUFFERED=1 \
7
+ PYTHONDONTWRITEBYTECODE=1
8
+
9
+ WORKDIR /app
10
+
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ build-essential \
13
+ cmake \
14
+ python3-dev \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ RUN pip install --upgrade pip setuptools wheel
18
+
19
+ RUN CMAKE_ARGS="-DGGML_BLAS=OFF" pip wheel --no-cache-dir --wheel-dir /wheels \
20
+ llama-cpp-python
21
+
22
  FROM python:3.10-slim
23
 
24
+ WORKDIR /app
25
+
26
+ # Настраиваем переменные
27
  ENV PYTHONUNBUFFERED=1 \
28
  HF_HOME=/home/user/cache \
29
  HOME=/home/user \
30
  PATH=/home/user/.local/bin:$PATH
31
 
 
 
 
32
  RUN apt-get update && apt-get install -y --no-install-recommends \
33
  curl \
34
  libgomp1 \
 
39
  USER user
40
  RUN mkdir -p $HF_HOME
41
 
42
+ COPY --from=builder /wheels /wheels
43
+
44
  COPY --chown=user requirements.txt requirements.txt
45
  RUN pip install --no-cache-dir --upgrade pip && \
46
+ pip install --no-cache-dir -r requirements.txt && \
47
+ pip install --no-cache-dir /wheels/*.whl
 
 
48
 
 
49
  COPY --chown=user app.py app.py
50
 
51
  EXPOSE 7860