dyweb / blog

Dongyue Tech Blog
https://blog.dongyueweb.com
14 stars 7 forks source link

[post] Build go project with private dependency using docker multi stage build #38

Open at15 opened 6 years ago

at15 commented 6 years ago

Type

Related

Description

Spent one day at work writing Dockerfile and Makefile. The code at work relies on many internal projects, on Jenkins, the Jenkins worker has access to all internal GithHub projects, however if I use a fully dockerized build locally and get vendor using glide install or dep install, it will fail because no access. The solution is to add ssh private key into container when build, and by using multi stage build, the build image is discarded right away and the runner image does not contain credentials.

Also had some interesting stuff like need to base64 encode and decode private key content, chmod 0400 ~/.ssh/id_rsa, add known host.

Update