How to do git pull from a private repo when docker build

What if we want go pull code from a private repo and build this code at go build time .
To goal this,i have do some tries.
1.Do RUN ADD /root/.ssh/id_rsa /root/.ssh/id_rsa
2.Use shell script in Docker file,the script do-ssh.sh is:

eval “$(ssh-agent)” && ssh-agent -s
chmod 0600 /root/.ssh/id_rsa
ssh-add /root/.ssh/id_rsa
git clone git@103.6.128.106:fw/product.git -b new

then, RUN do-ssh.sh
id_rsa` was add into agent,but it still do not work

By the way,i have aready read this issue
https://github.com/docker/docker/issues/6396
It seem that there have’t any way to do pull from a private repo successfully when docker build
Must i compile my code at docker run time?