Automated Dockerhub builds with multiple private repositories

Is there a way to connect to multiple private git repositories during dockerhub auto build? We are creating golang applications and have to β€œswitch” to other private repositories as part of our assembly, and at the moment they are failing because the docker cannot connect to them, only the target private repo.

The main repo is fine, as the deployment key is installed through Dockerhub, but all subsequent private repo imports do not work.

One way that I see is to create an image locally, β€œdocker” direct it to the docker hub, and then pull it out on the deployment side, which defeats the goal of the docker hub and automated build system. Another is to bake ssh keys in the base image, which is not a great idea.

Does anyone have a solution that does not include throwing ssh keys into images or creating locally?

Thank you very much.

+6
source share
1 answer

single ssh key

If you have only one ssh-key , adding it to the root ssh path in the Docker container ( /root/.ssh/id_rsa ) should be enough to successfully pull out your repositories. Depends on where your private-repos are, probably you should add some other configs in .ssh .

several ssh keys

If you have ssh-keys differences, I suggest you create a personal token for all your repositories. This way you can easily solve this problem. You must upgrade git -url to get:

[taken here: https://gist.github.com/shurcooL/6927554 ]

 git config --global url."https://${GITHUB_TOKEN}: x-oauth-basic@github.com /".insteadOf "https://github.com/" 

With this change, you can successfully create your docker container.


Using vendor -tool will help you with this. From go1.5 a sale function is available. We use Glide and save only links (not wholes projects).

0
source

Source: https://habr.com/ru/post/979481/


All Articles