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

Building fails for packages in subdirectories #29

Open jfindley opened 8 years ago

jfindley commented 8 years ago

Given an import path of github.com/foo/bar/baz, where the repo is github.com/foo/bar, building will fail.

Example:

docker run --rm \
        --privileged \
        -v /Users/jfindley/go/src/github.com/nutmegdevelopment/sumologic/filestream:/src \
        -e CGO_ENABLED=0 \
        -e LDFLAGS='-s -extldflags -static' \
        -v /var/run/docker.sock:/var/run/docker.sock \
        centurylink/golang-builder \
        localhost/filestream:latest
github.com/dleung/gotail (download)
Fetching https://gopkg.in/fsnotify.v1?go-get=1
Parsing meta tags from https://gopkg.in/fsnotify.v1?go-get=1 (status code 200)
get "gopkg.in/fsnotify.v1": found meta tag main.metaImport{Prefix:"gopkg.in/fsnotify.v1", VCS:"git", RepoRoot:"https://gopkg.in/fsnotify.v1"} at https://gopkg.in/fsnotify.v1?go-get=1
gopkg.in/fsnotify.v1 (download)
Fetching https://golang.org/x/sys/unix?go-get=1
Parsing meta tags from https://golang.org/x/sys/unix?go-get=1 (status code 200)
get "golang.org/x/sys/unix": found meta tag main.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
Fetching https://golang.org/x/sys?go-get=1
Parsing meta tags from https://golang.org/x/sys?go-get=1 (status code 200)
golang.org/x/sys (download)
github.com/nutmegdevelopment/sumologic (download)
package github.com/nutmegdevelopment/sumologic/upload: /go/src/github.com/nutmegdevelopment/sumologic exists but /go/src/github.com/nutmegdevelopment/sumologic/.git does not - stale checkout?
github.com/stretchr/testify

This is because build_environment.sh links /src into the GOPATH, making clones into the parent dir fail.

We are currently using this patch: https://github.com/nutmegdevelopment/golang-builder/commit/ced5b2148ce452a45313678d6329963a3213b287

Note that it also disabled the GO15VENDEREXPERIMENT stuff, as that's now part of current (1.6) go, so shouldn't be needed anymore.

We alos disabled godeps support as we had issues making that work too.

I can split the above patch into separate commits, if you're interested in accepting some/all of these changes.