Reputation: 81
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:
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
Upvotes: 8
Views: 2425
Reputation: 50
I had the same error thrown at me after trying to install a private package in a container via git. I could get it to work using the https
URL instead of ssh
.
It might help if you run the install command with -vvv
to get a more verbose error.
AFAICT, this seems to be an underlying issue with dulwich
.
If you really don't want to use https, I'd go report this on the corresponding poetry issue, hopefully the poetry team can find a workaround until dulwitch rolls out a fix.
Upvotes: 2