22# ARGUMENTS
33# ==============================================================================
44
5- # 定义CANN基础镜像,方便后续统一更新版本
5+ # Define the CANN base image for easier version updates later
66ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.1.rc1-910b-openeuler22.03-py3.10
77
8-
98# ==============================================================================
109# BUILD STAGE
11- # 编译所有二进制文件和库
10+ # Compile all binary files and libraries
1211# ==============================================================================
1312FROM ${CANN_BASE_IMAGE} AS build
1413
15- # 定义昇腾芯片型号,用于编译。默认为 Ascend910B3
14+ # Define the Ascend chip model for compilation. Default is Ascend910B3
1615ARG ASCEND_SOC_TYPE=Ascend910B3
1716
18- # -- 安装构建依赖 --
17+ # -- Install build dependencies --
1918RUN yum install -y gcc g++ cmake make git libcurl-devel python3 python3-pip && \
2019 yum clean all && \
2120 rm -rf /var/cache/yum
2221
23- # -- 设置工作目录 --
22+ # -- Set the working directory --
2423WORKDIR /app
2524
26- # -- 拷贝项目文件 --
25+ # -- Copy project files --
2726COPY . .
2827
29- # -- 设置CANN环境变量 (编译时需要 ) --
30- # 相比于 `source`,使用 ENV 可以让环境变量在整个镜像层中持久生效
28+ # -- Set CANN environment variables (required for compilation ) --
29+ # Using ENV instead of `source` allows environment variables to persist across the entire image layer
3130ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest
3231ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH}
3332ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH}
3433ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp
3534ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/runtime/lib64/stub:$LD_LIBRARY_PATH
36- # ... 您可以根据需要添加原始文件中其他的环境变量 ...
37- # 为了简洁,这里只列出核心变量,您可以将原始的ENV列表粘贴于此
35+ # ... You can add other environment variables from the original file as needed ...
36+ # For brevity, only core variables are listed here. You can paste the original ENV list here.
3837
39- # -- 编译 llama.cpp --
40- # 使用传入的 ASCEND_SOC_TYPE 参数,并增加通用编译选项
38+ # -- Build llama.cpp --
39+ # Use the passed ASCEND_SOC_TYPE argument and add general build options
4140RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh --force \
4241 && \
4342 cmake -B build \
@@ -47,91 +46,85 @@ RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh --force \
4746 . && \
4847 cmake --build build --config Release -j$(nproc)
4948
50- # -- 整理编译产物,方便后续阶段拷贝 --
51- # 创建一个lib目录存放所有.so文件
49+ # -- Organize build artifacts for copying in later stages --
50+ # Create a lib directory to store all .so files
5251RUN mkdir -p /app/lib && \
5352 find build -name "*.so" -exec cp {} /app/lib \;
5453
55- # 创建一个full目录存放所有可执行文件和Python脚本
54+ # Create a full directory to store all executables and Python scripts
5655RUN mkdir -p /app/full && \
5756 cp build/bin/* /app/full/ && \
5857 cp *.py /app/full/ && \
5958 cp -r gguf-py /app/full/ && \
6059 cp -r requirements /app/full/ && \
6160 cp requirements.txt /app/full/
62- # 如果您有 tools.sh 脚本,也请确保它在此处被拷贝
61+ # If you have a tools.sh script, make sure it is copied here
6362 # cp .devops/tools.sh /app/full/tools.sh
6463
65-
6664# ==============================================================================
6765# BASE STAGE
68- # 创建一个包含CANN运行时和通用库的最小基础镜像
66+ # Create a minimal base image with CANN runtime and common libraries
6967# ==============================================================================
7068FROM ${CANN_BASE_IMAGE} AS base
7169
72- # -- 安装运行时依赖 --
70+ # -- Install runtime dependencies --
7371RUN yum install -y libgomp curl && \
7472 yum clean all && \
7573 rm -rf /var/cache/yum
7674
77- # -- 设置CANN环境变量 (运行时需要 ) --
75+ # -- Set CANN environment variables (required for runtime ) --
7876ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest
7977ENV LD_LIBRARY_PATH=/app:${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH}
8078ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH}
8179ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp
82- # ... 您可以根据需要添加原始文件中其他的环境变量 ...
80+ # ... You can add other environment variables from the original file as needed ...
8381
8482WORKDIR /app
8583
86- # 从build阶段拷贝编译好的.so文件
84+ # Copy compiled .so files from the build stage
8785COPY --from=build /app/lib/ /app
8886
89-
9087# ==============================================================================
9188# FINAL STAGES (TARGETS)
9289# ==============================================================================
9390
9491# ## Target: full
95- # 包含所有工具、Python绑定和依赖的完整镜像
92+ # Complete image with all tools, Python bindings, and dependencies
9693# ==============================================================================
9794FROM base AS full
9895
9996COPY --from=build /app/full /app
10097
101- # 安装Python依赖
98+ # Install Python dependencies
10299RUN yum install -y git python3 python3-pip && \
103100 pip3 install --no-cache-dir --upgrade pip setuptools wheel && \
104101 pip3 install --no-cache-dir -r requirements.txt && \
105102 yum clean all && \
106103 rm -rf /var/cache/yum
107104
108- # 您需要提供一个 tools.sh 脚本作为入口点
105+ # You need to provide a tools.sh script as the entrypoint
109106ENTRYPOINT ["/app/tools.sh" ]
110- # 如果没有 tools.sh,可以设置默认启动 server
107+ # If there is no tools.sh, you can set the default to start the server
111108# ENTRYPOINT ["/app/llama-server"]
112109
113-
114110# ## Target: light
115- # 仅包含 llama-cli 的轻量级镜像
111+ # Lightweight image containing only llama-cli
116112# ==============================================================================
117113FROM base AS light
118114
119115COPY --from=build /app/full/llama-cli /app
120116
121-
122117ENTRYPOINT [ "/app/llama-cli" ]
123118
124-
125119# ## Target: server
126- # 仅包含 llama-server 的专用服务器镜像
120+ # Dedicated server image containing only llama-server
127121# ==============================================================================
128122FROM base AS server
129123
130124ENV LLAMA_ARG_HOST=0.0.0.0
131125
132126COPY --from=build /app/full/llama-server /app
133127
134-
135128HEALTHCHECK CMD [ "curl" , "-f" , "http://localhost:8080/health" ]
136129
137- ENTRYPOINT [ "/app/llama-server" ]
130+ ENTRYPOINT [ "/app/llama-server" ]
0 commit comments