drone-docker icon indicating copy to clipboard operation
drone-docker copied to clipboard

Add option to mount host ssh agent (--ssh)

Open ohenning opened this issue 3 years ago • 8 comments

PR Purpose This PR provides a new setting to the plugin:

ssh_agent-> Pass host ssh agent to the Image. Under the hood this triggers the --ssh option to be set when building the image (https://docs.docker.com/develop/develop-images/build_enhancements/#using-ssh-to-access-private-data-in-builds).

This get's really useful when it's required to access private repositories from inside the Image to build.

Additional Info For this to work, it's necessary to have DOCKER_BUILDKIT enabled. Example:

drone.yaml

- name: "publish"
   image: plugins/ecr
   environment:
     DOCKER_BUILDKIT: 1
   settings:
     repo: foo/bar
     ssh_agent: default

Dockerfile

COPY go.mod go.sum* ./
RUN --mount=type=ssh go mod download

the docker plugin documentation might have to be updated.

ohenning avatar Oct 13 '21 12:10 ohenning

Hi @ohenning can you have a look at the failing checks on this one?

We will have a look into this PR over the next few weeks (coming to end of quarter and have features to deliver!) to confirm it doesn't introduce any security vulnerabilities that we should be concerned about :)

Thanks for your work on this!

PS might also be worth a rebase!

d1wilko avatar Oct 19 '21 15:10 d1wilko

Hi @d1wilko , thanks for your feedback! Rebasing resolved the failing build! 👍

ohenning avatar Oct 22 '21 08:10 ohenning

Hey, @d1wilko! Any new thoughts on this feature? I could benefit from it as well 😃

lecardozo avatar May 12 '22 17:05 lecardozo

This is something we need for our drone builds, can you work at getting this merged @d1wilko ?

bkk-bcd avatar Jun 22 '22 11:06 bkk-bcd

Hey @ohenning

Looks like the branch has conflicts? Can you merge master please?

eoinmcafee00 avatar Jun 24 '22 09:06 eoinmcafee00

@jimsheldon @eoinmcafee00 I've addressed the merge conflicts in #369. Can someone take a look so we can get it merged in?

bkk-bcd avatar Jun 26 '22 12:06 bkk-bcd

Hey @ohenning

Have you been able to verify this change works? This change expects the ability to mount the ssh directory which the docker plugin doesn't support. Can you provide some screenshots of this working, please? Also, it still seems to be complaining about conflicts.

Cheers, Eoin

eoinmcafee00 avatar Jun 28 '22 10:06 eoinmcafee00

I couldn't get this to work, fixes in #369

bkk-bcd avatar Jul 09 '22 19:07 bkk-bcd