Issue: I am trying to add a bitbucket repo using an ssh key as a tool.poetry.dev.dependency in my pyproject.toml and have it installed in a docker container via docker compose. However, I encounter the following errors (see Errors) when I build the container.
Is there anything that I may be overlooking and/or suggestions to be able to pull a bitbucket repo as a dependency during poetry install in a docker container?
What I have done:
- I know the bitbucket dependency is the issue because when I exchange it to a local path to a whl file instead, the container builds correctly.
- I can install the dependency locally
- I can clone a different repo in the docker container
REFERENCES
Errors: HangupException
The remote server unexpectedly closed the connection.
at /usr/local/lib/python3.10/site-packages/dulwich/protocol.py:220 in read_pkt_line
216│
217│ try:
218│ sizestr = read(4)
219│ if not sizestr:
→ 220│ raise HangupException()
221│ size = int(sizestr, 16)
222│ if size == 0:
223│ if self.report_activity:
224│ self.report_activity(4, "read")
The following error occurred when trying to handle this error:
HangupException
Host key verification failed.
at /usr/local/lib/python3.10/site-packages/dulwich/client.py:1151 in fetch_pack
1147│ with proto:
1148│ try:
1149│ refs, server_capabilities = read_pkt_refs(proto.read_pkt_seq())
1150│ except HangupException as exc:
→ 1151│ raise _remote_error_from_stderr(stderr) from exc
1152│ (
1153│ negotiated_capabilities,
1154│ symrefs,
1155│ agent,
My Files/Commands: pyproject.toml
[tool.poetry.dependencies]
# Trial 1: I am trying to use ssh key to pull to repo (see docker build command) [1]
package_name = {git = "ssh://[email protected]/tenant/repo.git", tag = "v0.0.0"}
# Trial 2: I don't really want to use http because I don't want to have to feed in credentials [1]
package_name = {git = "https://[email protected]/tenant/repo.git", tag = "v0.0.0"}
# 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
package_name = {git="git+ssh://[email protected]/user/repo.git"}`
Dockerfile
ENV POETRY_VERSION=1.2.2
RUN pip install poetry==$POETRY_VERSION
COPY ./poetry.lock ./pyproject.toml ./
RUN poetry config installer.max-workers 4 \
&& poetry install --no-root`
Docker build command
docker build --no-cache --ssh default -t $IMAGE_NAME .
Docker compose command
docker compose build
Host key verification failed.
means that the SSH could not connect to the server, because it needs an interactive connection to accept the host key of the server (usually happens with y/n prompt). The host key mechanism prevents anyone to spoof your server (man-in-the-middle-attack). The secure way to solve this is to drop the host key to~/.ssh/known_host
. – Hydrograph