Files changed (1) hide show
  1. Dockerfile +10 -22
Dockerfile CHANGED
@@ -1,33 +1,21 @@
1
- # 1. 標準・軽量Debian OS(正規品)
2
- FROM python:3.10-slim
3
 
4
- # 2. 【超重要】爆速並列コンパイール「ninja-build」と必須コンパイラ入れ
5
- RUN apt-get update && apt-get install -y --no-install-recommends \
6
- build-essential \
7
- cmake \
8
- ninja-build \
9
- ca-certificates \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- # 3. Hugging Faceの標準ルール(ユーザー権限設定)
13
  RUN useradd -m -u 1000 user
14
  WORKDIR /home/user/app
15
- RUN chown user:user /home/user/app
16
 
17
  USER user
18
  ENV PATH="/home/user/.local/bin:$PATH"
19
 
20
- # 4. pip更新とHFツールの導
21
- RUN pip install --no-cache-dir --upgrade pip
22
  RUN pip install --no-cache-dir huggingface_hub
23
 
24
- # 5. 【大本命】Ninjaを使って爆速で自力ビルドする(30分はかかりません!2〜3分だけ待ってください!)
25
- ENV CMAKE_GENERATOR=Ninja
26
- RUN pip install --no-cache-dir "llama-cpp-python[server]"
27
-
28
- # 6. ポート公開
29
  EXPOSE 7860
30
 
31
- # 7. サーバー起動(Qwen2.5-Coderをダウンロードして起動
32
- CMD python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF', filename='qwen2.5-coder-1.5b-instruct-q4_k_m.gguf', local_dir='./model')" && \
33
- python -m llama_cpp.server --model ./model/qwen2.5-coder-1.5b-instruct-q4_k_m.gguf --host 0.0.0.0 --port 7860 --n_ctx 2048 --n_threads 2 --chat_format chatml
 
1
+ # 1. 組み立て作業は一切やめる!作者が公開している「完成済み公式イメージ」を使う
2
+ FROM ghcr.io/abetlen/llama-cpp-python:latest
3
 
4
+ # 2. Hugging Faceのルール(ユーザー権限)設定すために一時的にrootになる
5
+ USER root
 
 
 
 
 
 
 
6
  RUN useradd -m -u 1000 user
7
  WORKDIR /home/user/app
8
+ RUN chown -R user:user /home/user/app
9
 
10
  USER user
11
  ENV PATH="/home/user/.local/bin:$PATH"
12
 
13
+ # 3. AIモデルをダウンロードするためのツールだけれる(これは数秒で終わります)
 
14
  RUN pip install --no-cache-dir huggingface_hub
15
 
16
+ # 4. ポート公開
 
 
 
 
17
  EXPOSE 7860
18
 
19
+ # 5. モデルをダウンロードしてサーバー起動
20
+ CMD python3 -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF', filename='qwen2.5-coder-1.5b-instruct-q4_k_m.gguf', local_dir='./model')" && \
21
+ python3 -m llama_cpp.server --model ./model/qwen2.5-coder-1.5b-instruct-q4_k_m.gguf --host 0.0.0.0 --port 7860 --n_ctx 2048 --n_threads 2 --chat_format chatml