|
1 |
| -# 此Dockerfile适用于“无本地模型”的环境构建,如果需要使用chatglm等本地模型,请参考 docs/Dockerfile+ChatGLM |
2 |
| -# 如何构建: 先修改 `config.py`, 然后 docker build -t gpt-academic-nolocal-vs -f docs/GithubAction+NoLocal+Vectordb . |
3 |
| -# 如何运行: docker run --rm -it --net=host gpt-academic-nolocal-vs |
4 |
| -FROM python:3.11 |
5 |
| - |
6 |
| -# 指定路径 |
| 1 | +# 此Dockerfile适用于“无本地模型”的迷你运行环境构建 |
| 2 | +# 如果需要使用chatglm等本地模型或者latex运行依赖,请参考 docker-compose.yml |
| 3 | +# - 如何构建: 先修改 `config.py`, 然后 `docker build -t gpt-academic . ` |
| 4 | +# - 如何运行(Linux下): `docker run --rm -it --net=host gpt-academic ` |
| 5 | +# - 如何运行(其他操作系统,选择任意一个固定端口50923): `docker run --rm -it -e WEB_PORT=50923 -p 50923:50923 gpt-academic ` |
| 6 | + |
| 7 | +FROM ghcr.io/astral-sh/uv:python3.12-bookworm |
| 8 | + |
| 9 | +# 非必要步骤,更换pip源 (以下三行,可以删除) |
| 10 | +RUN echo '[global]' > /etc/pip.conf && \ |
| 11 | + echo 'index-url = https://mirrors.aliyun.com/pypi/simple/' >> /etc/pip.conf && \ |
| 12 | + echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf |
| 13 | + |
| 14 | +# 语音输出功能(以下1,2行更换阿里源,第3,4行安装ffmpeg,都可以删除) |
| 15 | +RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \ |
| 16 | + sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \ |
| 17 | + apt-get update |
| 18 | +RUN apt-get install ffmpeg -y |
| 19 | +RUN apt-get clean |
| 20 | + |
| 21 | +# 进入工作路径(必要) |
7 | 22 | WORKDIR /gpt
|
8 | 23 |
|
9 |
| -# 装载项目文件 |
| 24 | +# 安装大部分依赖,利用Docker缓存加速以后的构建 (以下两行,可以删除) |
| 25 | +COPY requirements.txt ./ |
| 26 | +RUN uv venv --python=3.12 && uv pip install --verbose -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ |
| 27 | +RUN uv venv --python=3.12 && uv pip install aliyun-python-sdk-core==2.13.3 pyOpenSSL webrtcvad scipy git+https://github.com/aliyun/alibabacloud-nls-python-sdk.git |
| 28 | +RUN uv venv --python=3.12 && uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
| 29 | +RUN uv venv --python=3.12 && uv pip install transformers protobuf langchain sentence-transformers faiss-cpu nltk beautifulsoup4 bitsandbytes tabulate icetk --upgrade |
| 30 | +RUN uv venv --python=3.12 && uv pip install unstructured[all-docs] --upgrade |
| 31 | +ENV PATH="/gpt/.venv/bin:$PATH" |
| 32 | +RUN python -c 'import loguru' |
| 33 | + |
| 34 | +# 装载项目文件,安装剩余依赖(必要) |
10 | 35 | COPY . .
|
| 36 | +RUN uv venv --python=3.12 && uv pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ |
11 | 37 |
|
12 |
| -# 安装依赖 |
13 |
| -RUN pip3 install -r requirements.txt |
14 |
| - |
15 |
| -# 安装知识库插件的额外依赖 |
16 |
| -RUN apt-get update && apt-get install libgl1 -y |
17 |
| -RUN pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
18 |
| -RUN pip3 install transformers protobuf langchain sentence-transformers faiss-cpu nltk beautifulsoup4 bitsandbytes tabulate icetk --upgrade |
19 |
| -RUN pip3 install unstructured[all-docs] --upgrade |
20 |
| -RUN python3 -c 'from check_proxy import warm_up_vectordb; warm_up_vectordb()' |
21 |
| - |
22 |
| -# edge-tts需要的依赖 |
23 |
| -RUN apt update && apt install ffmpeg -y |
| 38 | +# # 非必要步骤,用于预热模块(可以删除) |
| 39 | +RUN python -c 'from check_proxy import warm_up_modules; warm_up_modules()' |
24 | 40 |
|
25 |
| -# 可选步骤,用于预热模块 |
26 |
| -RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()' |
27 |
| -RUN python3 -m pip cache purge && apt-get clean |
| 41 | +ENV CGO_ENABLED=0 |
28 | 42 |
|
| 43 | +# 启动(必要) |
| 44 | +CMD ["bash", "-c", "python main.py"] |
29 | 45 |
|
30 | 46 | # 启动
|
31 | 47 | CMD ["python3", "-u", "main.py"]
|
0 commit comments