在 docker 容器中将 github repo 导入为诗歌中的依赖项

a18*_*859 7 bitbucket docker docker-compose python-poetry

问题:\n我正在尝试使用 ssh 密钥作为 tool.poetry.dev.dependency 在我的 pyproject.toml 中添加 bitbucket 存储库,并通过 docker compose 将其安装在 docker 容器中。但是,我在构建容器时遇到以下错误(请参阅错误)。

\n

在 Docker 容器中安装诗歌期间,有什么我可能会忽略的事情和/或建议能够将 bitbucket 存储库作为依赖项拉出吗?

\n

我做了什么:

\n
    \n
  • 我知道 bitbucket 依赖性是问题所在,因为当我将其交换到 whl 文件的本地路径时,容器会正确构建。
  • \n
  • 我可以在本地安装依赖项
  • \n
  • 我可以在 docker 容器中克隆不同的存储库
  • \n
\n
\n

参考

\n

错误:\nHangupException

\n

远程服务器意外关闭了连接。

\n

在 /usr/local/lib/python3.10/site-packages/dulwich/protocol.py:220 中 read_pkt_line

\n
   216\xe2\x94\x82 \n   217\xe2\x94\x82         try:\n   218\xe2\x94\x82             sizestr = read(4)\n   219\xe2\x94\x82             if not sizestr:\n \xe2\x86\x92 220\xe2\x94\x82                 raise HangupException()\n   221\xe2\x94\x82             size = int(sizestr, 16)\n   222\xe2\x94\x82             if size == 0:\n   223\xe2\x94\x82                 if self.report_activity:\n   224\xe2\x94\x82                     self.report_activity(4, "read")\n
Run Code Online (Sandbox Code Playgroud)\n

尝试处理此错误时发生以下错误:

\n

挂断异常

\n

主机密钥验证失败。

\n

在 fetch_pack 中的 /usr/local/lib/python3.10/site-packages/dulwich/client.py:1151

\n
   1147\xe2\x94\x82         with proto:\n   1148\xe2\x94\x82             try:\n   1149\xe2\x94\x82                 refs, server_capabilities = read_pkt_refs(proto.read_pkt_seq())\n   1150\xe2\x94\x82             except HangupException as exc:\n \xe2\x86\x92 1151\xe2\x94\x82                 raise _remote_error_from_stderr(stderr) from exc\n   1152\xe2\x94\x82             (\n   1153\xe2\x94\x82                 negotiated_capabilities,\n   1154\xe2\x94\x82                 symrefs,\n   1155\xe2\x94\x82                 agent,\n
Run Code Online (Sandbox Code Playgroud)\n

我的文件/命令:\npyproject.toml

\n
    [tool.poetry.dependencies]\n\n    # Trial 1: I am trying to use ssh key to pull to repo (see docker build command) [1]\n    package_name = {git = "ssh://git@bitbucket.org/tenant/repo.git", tag = "v0.0.0"}\n\n    # Trial 2: I don't really want to use http because I don't want to have to feed in credentials [1]\n    package_name = {git = "https://user@bitbucket.org/tenant/repo.git", tag = "v0.0.0"}\n\n    # Trial 3: I didn't know if it was just a bitbucket thing so I had also tried with git and it works locally just not in a docker container\n    package_name = {git="git+ssh://git@github.com/user/repo.git"}`\n\n
Run Code Online (Sandbox Code Playgroud)\n

Dockerfile

\n
    ENV POETRY_VERSION=1.2.2\n    RUN pip install poetry==$POETRY_VERSION\n    COPY ./poetry.lock ./pyproject.toml ./\n    RUN poetry config installer.max-workers 4 \\\n        && poetry install --no-root`\n
Run Code Online (Sandbox Code Playgroud)\n

Docker 构建命令

\n
    docker build --no-cache --ssh default -t $IMAGE_NAME .\n
Run Code Online (Sandbox Code Playgroud)\n

Docker 撰写命令

\n
    docker compose build\n
Run Code Online (Sandbox Code Playgroud)\n

小智 1

在尝试通过 git 在容器中安装私有包后,我遇到了同样的错误。我可以使用 https 而不是 ssh 让它工作。

如果您运行安装命令以-vvv获取更详细的错误,这可能会有所帮助。

AFAICT,这似乎是dulwich.

如果你真的不想使用 https,我会在相应的诗歌问题上报告这一点,希望诗歌团队能够找到解决方法,直到 dulwitch 推出修复程序。