-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (43 loc) · 1.73 KB
/
Dockerfile
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
51
52
53
54
55
56
57
58
ARG BASE_IMAGE=ubuntu:20.04
FROM ${BASE_IMAGE} AS build
ARG CMAKE_ARGS="-DGGML_CUBLAS=OFF"
WORKDIR /chatglm.cpp
# apt
RUN \
sed -e "s/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g" \
-e "s/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g" -i /etc/apt/sources.list && \
apt update && \
DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends \
gcc g++ make python3-dev python3-pip python3-venv && \
rm -rf /var/lib/apt/lists/*
# pip
RUN \
python3 -m pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple pip && \
python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
python3 -m pip install --no-cache-dir build cmake
ARG PATH=${PATH}:/usr/local/bin
ADD . .
# build cpp binary
RUN \
cmake -B build ${CMAKE_ARGS} && \
cmake --build build -j --config Release
# build python binding
RUN \
CMAKE_ARGS=${CMAKE_ARGS} python3 -m build --wheel
FROM ${BASE_IMAGE}
WORKDIR /chatglm.cpp
RUN \
sed -e "s/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g" \
-e "s/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g" -i /etc/apt/sources.list && \
apt update && \
DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends \
python3 python3-pip && \
rm -rf /var/lib/apt/lists/*
COPY --from=build /chatglm.cpp/build/bin/main /chatglm.cpp/build/bin/main
COPY --from=build /chatglm.cpp/dist/ /chatglm.cpp/dist/
ADD examples examples
RUN \
python3 -m pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple pip && \
python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
python3 -m pip install --no-cache-dir -f dist 'chatglm-cpp[api]' && \
rm -rf dist