Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker autobuild with git private submodule

I have two private repositories on GitHub called dashboard and ui. I defined ui as a git submodule of dashboard, and I configured docker to autobuild dashboard on every changes on a specific branch.

I read this documentation https://docs.docker.com/docker-hub/builds/, but when I try to setup the deploy key given by docker in my ui's settings, it says "Key already in use". Indeed, this key is already used by dashboard to allow docker to autobuild this repo!

Here is my docker build log:

Error:

Failed to clone repository: Cloning into '/tmp/build_byaxhis7sznbvmb6wgwzm6n'...
Submodule 'app/styles/ui' ([email protected]:yllieth/ui.git) registered for path 'app/styles/ui'
Cloning into 'app/styles/ui'...


Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Clone of '[email protected]:yllieth/ui.git' into submodule path 'app/styles/ui' failed

Dockerfile: None

Docker doesn't find any Dockerfile even if I have one defined in my dashboard repo. So, I won't be able to give it any instructions or add another SSH key.

If anyone has an idea about how using autobuild with private repos and git submodule, I'm interested!!

like image 292
Sylvain Avatar asked Oct 02 '14 08:10

Sylvain


2 Answers

If your GitHub repository contains links to private submodules, you'll get an error message in your build. Normally, the Docker Hub sets up a deploy key in your GitHub repository. Unfortunately, GitHub only allows a repository deploy key to access a single repository. As a workaround, you need to create a dedicated user account in GitHub and attach the automated build's deploy key to that account. This dedicated build account can be limited to read-only access to just the repositories required to build.

A guy already initiated the pull request for the update in docker document. He also included the screenshots that might help you with this problem.

like image 72
Sabin Avatar answered Sep 20 '22 05:09

Sabin


This is ugly, but you could create a machine-user as github calls them, and add the deploy key to it as the user's key (after removing it from deploy keys). Then add that user as a read only user to each repo needed for that build.

I am waiting to hear from the docker team on something better.

like image 33
Lance Hudson Avatar answered Sep 21 '22 05:09

Lance Hudson