I've been digging to solve the problem during docker build stages of accessing private repos. Seems like using 'tokens' is the easiest and reasonably secure way of achieving this.
I came across an article, explaining this. In the comments someone suggested an improvement to add a github token. I cannot get it to work inside docker. How can I change the .gitconfig
and have git always use the token?
This command needs to be change to using the token:
RUN echo "[url \"[email protected]:\"]\n\tinsteadOf = https://github.com/" >> /root/.gitconfig
The comment:
A better approach would be to generate an api token with read only access to that repo and using something like
git config --global url."https://${TOKEN}@github.com/".insteadOf "https://github.com/"
. This way you don't need a wrapper script or ssh host key checking, nor do you need bake your all access
It would be great if someone could help me cross the bridge. Thx
I solved it by running the following RUN command. Make sure, to have the correct rights when generating the token on github.
FROM golang:1.9
RUN git config --global url."https://USERNAME:[email protected]/".insteadOf "https://github.com/"
....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With