CenturyLinkLabs / golang-builder

Containerized build environment for compiling an executable Golang package and packaging it in a light-weight Docker container.
Apache License 2.0
398 stars 85 forks source link

Unable to use packages in private repositories #18

Open bbrks opened 8 years ago

bbrks commented 8 years ago

Not sure if this is possible, feasible, or even out of scope, as my project does not strictly follow the sample hierarchy... But I'm trying to build docker images for a bunch of microservices. All of these microservices share a single authentication middleware function.

All of these services are stored in separate private repositories. When I try using golang-builder, I get 403s from the imported private repos for obvious reasons.

$ docker run --rm -v "$(pwd):/src" -v /var/run/docker.sock:/var/run/docker.sock centurylink/golang-builder
# cd .; git ls-remote https://bitbucket.org/xxx/auth
fatal: could not read Username for 'https://bitbucket.org': No such device or address
# cd .; hg identify https://bitbucket.org/xxx/auth
abort: HTTP Error 404: Not Found
package bitbucket.org/xxx/auth/middleware: https://api.bitbucket.org/1.0/repositories/xxx/auth: 403 FORBIDDEN

Is it possible to either; a) use git/ssh credentials in build image b) copy third-party imports from the $GOPATH/src directory at the same time as $(pwd), and use them in the build, then run a "go get" for any missing public imports.

I have found a workaround, by locally cross-compiling to linux, then running docker build myself, but this does have drawbacks... The person doing the build needs Go installed to compile stuff. Using golang-builder, anybody with Docker can run the build.

GOOS="linux" go build
docker build -t yyyservice
docker-compose up