Docker Community Forums

Share and learn in the Docker community.

Automated builds with submodules


(Jeff) #1

If you’re using a private submodule in your repo, you have to generate an SSH key for your source code provider and create a Build Environment Variable called SSH_PRIVATE with that key. As documented here.

Docker Cloud uses a git shallow clone to check out your repo and then switches branches if necessary. The clone runs with --recursive, meaning your submodules are fetched automatically. Since the clone doesn’t specify a branch, and instead switches branches AFTER it does the clone, if your submodule doesn’t exist on your default branch (or is using a different reference hash from your target branch), it won’t be fetched by the recursive clone.

In order to get around this, you need to create a post_checkout file in hooks/ to init and update your submodules. Here’s an example of my hooks/post_checkout:

git submodule update --init --recursive

I hope this helps anyone else who may be stuck trying to troubleshoot using submodules in Docker Cloud.

(Mahmoud Ahmed) #2

Is there a way to override the initial clone command?