Fix README for using multiple deploy keys in docker #164
+2
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR;
Multiple deploy keys in docker doesn't work after following everything in README. Loading
.gitconfig
into git in docker fixed it.Summary
We are using multiple Github deploy keys in docker for PIP to install dependencies from multiple private Github repositories. However, after doing everything from the webfactory/ssh-agent README, including adding comment when generating keys and copying
.gitconfig
and.ssh/
into docker, the multiple deploy keys still didn't work. We print out the verbose log forgit ssh
when doing PIP install by usingRUN --mount=type=ssh GIT_SSH_COMMAND="ssh -v" pip install -r /requirements.txt
. Turns out that it was blindly accepting the first key (repo-a) even though it should use the second key (repo-b) which is way it couldn't fetch from the repo-b. After some research, the webfactory/ssh-agent depends on the customized.gitconfig
file to map the correct ssh key to the correct repository link. Then we did aRUN git config -l
in the Dockerfile and the output was empty which means that although we are copying the.gitconfig
file into the docker image, it was not loaded into git config. So after addingRUN mv /root/.gitconfig /etc/gitconfig
into the Dockerfile, the PIP install started working. In conclusion, the.gitconfig
config file doesn't do anything sitting in the/root
folder.Following was the original error message excluding sensitive information that helped us figure out the root cause:
Following was the log of successfully using multiple deploy keys in docker:
Example Github Actions YAML
Example Dockerfile
Example PIP requirements.txt