#OK... how to handle `--mount=type=ssh` in Dockerfiles within dagger?

1 messages Β· Page 1 of 1 (latest)

safe tendon
#

I finally figured out why some builds were taking forever--they were relying on a private git repo, and our dockerfiles were using --mount=type=ssh. I was mounting my .ssh directory into the dagger task container just fine, but while I can't see the output, I'm pretty sure that it's sitting there waiting for me to type my passphrase.

Now, our old build process was using ssh-agent, and we can probably manage that but the passthrough described elsewhere for SSH_AUTH_SOCK was a little cosmic. The way to interact by mounting .ssh (https://github.com/dagger/dagger/blob/ea275a3bafbc5b5c611e0b81bf2dd8a8add72f6b/docs/plans/docker-cli-run/ssh.cue#L14-L21) doesn't look like it handles keys with passphrases.

I'm old-fashioned enough to want passphrases; is the SSH_AUTH_SOCK route the only way to handle this?

#

(this is for a docker.#Run command which then uses a build tool to build from a dockerfile which internally has a mount=type=ssh)

safe tendon
#

(well, the ssh_auth_sock route actually did work, but it is somewhat more painful than I'd prefer. Still... it makes sense, just a mite confusing)

coral hinge
#

What build tool do you use ? What does the operation look like ?
You do not rely on docker.#BuildI presume ?

Because, we're using docker's frontend for docker.#Build operations, but I don't know if it automatically retrieves that instruction or if we shall still pass it

safe tendon
#

Ah, sure. No, I'm using the pants build tool (which itself runs docker) from within docker.#Run... forwarding the SSH_AUTH_SOCK manually does do the trick (mostly).

coral hinge
#

@warm fern would it make sense/ do you see any security concern to also forward the ssh-agent inside our core.build to accept Dockerfiles relying on mount=type=ssh. Also to core.run, as some users apparently rely on other build tools (pants) ?

I can create the issue and corresponding PR, if you think it's valuable

warm fern
split roost
molten goblet
split roost
molten goblet
coral hinge
molten goblet
coral hinge
# molten goblet We could change `v0.2` to do this, yes. But I'm currently focused on getting the...

I might have misunderstood something then πŸ˜‡ From my perspective, all we have to do (in v0.3 engine), is to add this llb operation as an ops, and Buildkit would automatically forward the ssh connection to the container: it would 1) automatically forward it to the dockerfile.v0 ; 2) be the same for the run operation. We already do that for the v0.3 core.git operation. I don't see why the socket mount is required here, but it is probably a lack of vision on my side πŸ˜‡