Skip to content

Commit

Permalink
fix: docker imge issues #419 #425 (#426)
Browse files Browse the repository at this point in the history
* fix: docker imge issues #419 #425

* feat(docker): allow external PIP_INDEX_URL via build-arg
  • Loading branch information
isanwenyu authored Jan 13, 2024
1 parent 606215b commit 2258b88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM python:3.10 AS builder
WORKDIR /app
COPY requirements.txt .
RUN python3 -m venv .venv && .venv/bin/pip install --no-cache-dir -r requirements.txt
# 设置默认的源地址为 PyPI 官方源
ARG PIP_INDEX_URL=https://pypi.org/simple
# 使用 ARG 定义的变量作为 pip 源地址
RUN python3 -m venv .venv && .venv/bin/pip install --no-cache-dir -r requirements.txt -i ${PIP_INDEX_URL}

FROM python:3.10-slim

Expand All @@ -14,4 +17,4 @@ ENV XDG_CONFIG_HOME=/config
ENV XIAOGPT_PORT=9527
VOLUME /config
EXPOSE 9527
ENTRYPOINT [".venv/bin/python3","xiaogpt.py"]
ENTRYPOINT ["/app/.venv/bin/python3", "xiaogpt.py"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ docker run -v <your-config-dir>:/config yihong0618/xiaogpt --config=/config/conf
docker build -t xiaogpt .
```

如果在安装依赖时构建失败或安装缓慢时,可以在构建 Docker 镜像时使用 `--build-arg` 参数来指定国内源地址:

```sh
docker build --build-arg PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple -t xiaogpt .
```

如果需要在Apple M1/M2上编译x86

```shell
Expand Down

0 comments on commit 2258b88

Please sign in to comment.