coze-dev / coze-dev/coze-studio

用backend/Dockerfile从本地构建后端映像出错。

Open
#647 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21.6k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

用下面的命令在本地从最新的源码构建opencoze/opencoze:latest 映像。
```
cd /home/jean/coze-studio
make fe
docker build -t opencoze/opencoze:latest -f backend/Dockerfile .
```
报错:
```
--------------------
30 | # Install Python build dependencies, create venv, install packages, then remove build deps
31 | >>> RUN apk add --no-cache --virtual .python-build-deps build-base py3-pip git && \
32 | >>> python3 -m venv --copies --upgrade-deps /app/.venv && \
33 | >>> # Activate venv and install packages
34 | >>> . /app/.venv/bin/activate && \
35 | >>> # If you want to use other third-party libraries, you can install them here.
36 | >>> pip install urllib3==1.26.16 && \
37 | >>> pip install --no-cache-dir h11==0.16.0 httpx==0.28.1 pillow==11.2.1 pdfplumber==0.11.7 python-docx==1.2.0 numpy==2.3.1 && \
38 | >>> # Deactivate (optional, as RUN is a new shell)
39 | >>> # deactivate && \
40 | >>> # Remove build dependencies
41 | >>> apk del .python-build-deps
42 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apk add --no-cache --virtual .python-build-deps build-base py3-pip git && python3 -m venv --copies --upgrade-deps /app/.venv && . /app/.venv/bin/activate && pip install urllib3==1.26.16 && pip install --no-cache-dir h11==0.16.0 httpx==0.28.1 pillow==11.2.1 pdfplumber==0.11.7 python-docx==1.2.0 numpy==2.3.1 && apk del .python-build-deps" did not complete successfully: exit code: 22
```
问了ChatGPT给出的答复是:
```
exit code 22 是 curl 和部分 shell 命令的常见通用错误码,意思是:

命令执行失败,通常是某个步骤返回非零状态码。

在你的 RUN 命令中,最可能出错的地方是:

python3 -m venv --copies --upgrade-deps /app/.venv
Alpine 的 Python 有时不包含 ensurepip,会导致 venv 创建失败。

. /app/.venv/bin/activate
在 RUN 命令中使用 source(或 .)激活虚拟环境 对后续命令并不生效,因为每个 RUN 都是新的 shell。

pip install 的某些库或依赖编译失败,比如 pillow、numpy,需要额外依赖。
```
确定是. /app/.venv/bin/activate没有生效,Dockerfile作如下修改后build成功了。
```
## Install Python build dependencies, create venv, install packages, then remove build deps
# RUN apk add --no-cache --virtual .python-build-deps build-base py3-pip git && \
# python3 -m venv --copies --upgrade-deps /app/.venv && \
# # Activate venv and install packages
# . /app/.venv/bin/activate && \
# # If you want to use other third-party libraries, you can install them here.
# pip install urllib3==1.26.16 && \
# pip install --no-cache-dir h11==0.16.0 httpx==0.28.1 pillow==11.2.1 pdfplumber==0.11.7 python-docx==1.2.0 numpy==2.3.1 && \
# # Deactivate (optional, as RUN is a new shell)
# # deactivate && \
# # Remove build dependencies
# apk del .python-build-deps

RUN apk add --no-cache --virtual .python-build-deps build-base py3-pip git && \
python3 -m venv /app/.venv && \
/app/.venv/bin/pip install --upgrade pip setuptools wheel && \
/app/.venv/bin/pip install urllib3==1.26.16 && \
/app/.venv/bin/pip install --no-cache-dir h11==0.16.0 httpx==0.28.1 pillow==11.2.1 pdfplumber==0.11.7 python-docx==1.2.0 numpy==2.3.1 && \
apk del .python-build-deps
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.