Closed odigity closed 8 years ago
@odigity I was curious about this, so I looked into it. The issue is that by default the builder tries to place the compiled binary (in this case a file named vault
) into the $pkgName
directory ($GOPATH/src/github.com/hashicorp/vault
). Since the vault project has a directory inside it called vault
, the compiled binary can't get copied. Hence the error you were seeing.
I forked the project and got it working by adding an output directory called bin
by default, so now the binary will get copied into $GOHOME/src/github.com/hashicorp/vault/bin
.
I cloned your repo (chiefly/golang-builder/master), ran docker build .
in the build/ dir, and ran my original docker run command with your image instead of centurylinklabs/golang-builder which resulted in a vault binary being created in bin/.
Your fix works! Thanks.
(Going to wait till the PR is merged and a new image is pushed to Docker Hub before continuing so I don't have to code to a fork and then update later.)
PR#13 accepted (https://github.com/CenturyLinkLabs/golang-builder/pull/13) - closing this issue.
Hello @chiefy, I still got the above error, do you have an idea what I'm doing wrong?
╭─ in ~/projects/go/src/github.com/hashicorp/vault on master ✘ (origin/master)
╰$ ls
CHANGELOG.md Godeps README.md builtin helper main.go physical terraform vendor
CONTRIBUTING.md LICENSE api cli http main_test.go scripts test version
Dockerfile Makefile audit command logical make.bat shamir vault website
╭─ in ~/projects/go/src/github.com/hashicorp/vault on master ✘ (origin/master)
╰$ docker run --rm -v "$(pwd):/src" -v /var/run/docker.sock:/var/run/docker.sock centurylink/golang-builder
Building github.com/hashicorp/vault
go install github.com/hashicorp/vault: build output "vault" already exists and is a directory
╭─ in ~/projects/go/src/github.com/hashicorp/vault on master ✘ (origin/master)
╰$ echo $GOPATH
/Users/leif.hanack/projects/go
╭─ in ~/projects/go/src/github.com/hashicorp/vault on master ✘ (origin/master)
╰$ echo $GOROOT
/usr/local/Cellar/go/1.6/libexec
The golang-builder
image is 3 weeks old so it should be the one, that is containing your fix:
centurylink/golang-builder latest 9491cd026567 3 weeks ago 754.8 MB
My Dockerfile
contains
FROM scratch
EXPOSE 8200
COPY vault /
ENTRYPOINT ["/vault"]
Thanks a lot, Leif
Hi there,
for me it looks like this issue isn't fixed and should be opened until PR #15 is somehow integrated. Issue #13 alone did not solves it. If I apply #15 locally everything is fine.
Regards, Leif
@leifhanack feel free to use my fork :mask:
This issue is long closed, but just in case anyone stumbles upon it again, I just wanted to offer two additional solutions. The issue occurs because go build is trying to make a vault
binary, but there's already a vault
directory it doesn't want to overwrite, which is good.
This can be worked around by using a different location for the generated binary to live:
$ go build -o=bin/vault
However, even better would be doing it how we do it on the Vault team:
make bootstrap
make build
This can be found in the README but may not have been documented at the time of this issue.
I'm trying to use golang-builder to build an image for Vault (https://vaultproject.io/), and getting the above error.
I read the golang-builder README, cloned the vault repo (main package in root), created a Dockerfile in root:
Then ran the build command:
And got this:
I'm not fluent in Go, but when I posted the issue to the vault repo, one of the maintainers said:
https://github.com/hashicorp/vault/issues/165#issuecomment-154210535