logo
57
174
WeChat Login

在 .ide/Dockerfile 中定义了 python 镜像,但在【云原生开发】环境中没有 python 环境#1714

Resolved
created 2025-08-20
Edit

简单描述一下问题和重现方式

.ide/Dockerfile 的文件定义如下,

# .ide/Dockerfile

# 基础镜像
FROM python:3.11.6

# 安装 code-server 和 vscode 常用插件
RUN curl -fsSL https://code-server.dev/install.sh | sh \
  && code-server --install-extension cnbcool.cnb-welcome \
  && code-server --install-extension redhat.vscode-yaml \
  && code-server --install-extension dbaeumer.vscode-eslint \
  && code-server --install-extension waderyan.gitblame \
  && code-server --install-extension mhutchie.git-graph \
  && code-server --install-extension donjayamanne.githistory \
  && code-server --install-extension tencent-cloud.coding-copilot \
  && code-server --install-extension ms-python.python \
  && code-server --install-extension ms-python.debugpy \
  && echo done

# 安装 ssh 服务,用于支持 VSCode 等客户端通过 Remote-SSH 访问开发环境(也可按需安装其他软件)
RUN apt-get update && apt-get install -y git wget unzip openssh-server

# 指定字符集支持命令行输入中文(根据需要选择字符集)
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8

RUN pip install -r requirements.txt

但是【云原生开发】环境中,没有 python 环境

➜  /workspace git:(main) python --version
zsh: command not found: python
➜  /workspace git:(main) 
Developer

RUN pip install -r requirements.txt

我猜 这句话会导致构建失败

可以提供下构建日志链接我们好确认

withdrew a comment.
Creator

@jingjingwu(晶晶)
日志链接:https://cnb.cool/weseen.org.cn/pharmacokinetic-calculation-system/api-tdesign-starter/-/build/logs/cnb-qco-1j335h653
下面贴上了部分内容,确实是 RUN pip install -r requirements.txt 导致出错了

[build .ide/Dockerfile] #7 [4/4] RUN pip install -r requirements.txt
[build .ide/Dockerfile] #7 2.744 ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
[build .ide/Dockerfile] #7 2.851 
[build .ide/Dockerfile] #7 2.851 [notice] A new release of pip is available: 23.2.1 -> 25.2
[build .ide/Dockerfile] #7 2.851 [notice] To update, run: pip install --upgrade pip
[build .ide/Dockerfile] #7 ERROR: process "/bin/sh -c pip install -r requirements.txt" did not complete successfully: exit code: 1
[build .ide/Dockerfile] ------
[build .ide/Dockerfile]  > [4/4] RUN pip install -r requirements.txt:
[build .ide/Dockerfile] 2.744 ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
[build .ide/Dockerfile] 2.851 
[build .ide/Dockerfile] 2.851 [notice] A new release of pip is available: 23.2.1 -> 25.2
[build .ide/Dockerfile] 2.851 [notice] To update, run: pip install --upgrade pip
[build .ide/Dockerfile] ------
[build .ide/Dockerfile] Dockerfile:26
[build .ide/Dockerfile] --------------------
[build .ide/Dockerfile]   24 |     ENV LANGUAGE C.UTF-8
[build .ide/Dockerfile]   25 |     
[build .ide/Dockerfile]   26 | >>> RUN pip install -r requirements.txt
[build .ide/Dockerfile]   27 |     
[build .ide/Dockerfile] --------------------
[build .ide/Dockerfile] ERROR: failed to solve: process "/bin/sh -c pip install -r requirements.txt" did not complete successfully: exit code: 1

[build .ide/Dockerfile] Job finished,code: 1,duration: 1m 32s

- endpoint 36000 start...

你Dockerfile中都没有添加 requirements.txt 这个文件, pip install -r requirements.txt 肯定会失败啊

Creator

@jingjingwu(晶晶) @lixiaofei(李小飞) 请问【云原生构建】只能看到 .ide/Dockerfile 这个文件吗?哪里能看到源代码目录?

Developer

构建.ide/Dockerfile 文件需要依赖的文件,需要专门声明

参考这个:https://docs.cnb.cool/zh/build/grammar.html#docker。by 和 versionBy

1
added labels
使用问题:用法咨询
Resolved ISSUE
Assignee
None yet
Label
使用问题:用法咨询
Priority
None yet
Time period
-
Property
Add custom properties to record and label key information
Participant