Skip to content

no buildable Go source files #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CWSpear opened this issue Jun 8, 2016 · 2 comments
Closed

no buildable Go source files #171

CWSpear opened this issue Jun 8, 2016 · 2 comments

Comments

@CWSpear
Copy link

CWSpear commented Jun 8, 2016

Disclaimer: I'm not normally a Go developer, so some of my terms may not be quite right.

I'm trying to build a Docker plugin that use the go-plugins-helpers from Docker and I wanted the binary to run in Docker alpine, but alpine doesn't have the linked dynamic binaries or whatever, so I was reading up that I need to set CGO_ENABLED=0 when building. I've tried a few different build commands, including:

CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-s' -o bin/linux/amd64/local-persist -v
CGO_ENABLED=0 go build -a -tags netgo -a -o bin/linux/amd64/local-persist -v

(Tried that last one with and without CGO_ENABLED flag. No error, but still won't run in alpine.)

I keep getting this error:

../github.com/docker/go-plugins-helpers/sdk/unix_listener.go:12:2: no buildable Go source files in /go/src/github.com/coreos/go-systemd/util
make: *** [binary-linux-amd64] Error 1

Steps to reproduce yourself:

git clone https://github.com/CWSpear/local-persist
cd local-persist
docker run -it -v `pwd`:/go/src/app  golang:onbuild bash
# now you'll be inside the docker container, next run:
export CGO_ENABLED=0
go get -v -d
go build [whatever flags] .

See docker/go-plugins-helpers#50

@lucab
Copy link
Contributor

lucab commented Jun 8, 2016

github.com/coreos/go-systemd/util needs cgo, but CGO_ENABLED=0 disables cgo. I guess that's why the build is failing.

My suggestion is that you remove the CGO_ENABLED=0 when building, and bring libsystemd.so into the image hosting your plugin. However, I'm not sure I've fully understood why you need to run systemd-related code in alpine (which is one of the few distros no supporting it)

@CWSpear
Copy link
Author

CWSpear commented Jun 8, 2016

I don't know why I need systemd-related code either. The plugin is a Docker Volume plugin, and one of the options is to run it as a container. I wanted the container to be small, since it's just doing one thing, so that's why I thought of alpine. It appears that it's needed by unix_listener.go, so something in there needs it to run this plugin.

How can I "bring libsystemd.so into the image," or what are alternatives to get something like my plugin's binary running in a minimal image.

gyuho added a commit to gyuho/etcd that referenced this issue Aug 11, 2016
heyitsanthony pushed a commit to heyitsanthony/go-systemd that referenced this issue Aug 12, 2016
Some projects don't need the CGO functions in the util package;
split out the functions into a separate file so CGO_ENABLED=0
works if those functions are never used.

Fixes coreos#171
heyitsanthony pushed a commit to heyitsanthony/go-systemd that referenced this issue Aug 12, 2016
Some projects don't need the CGO functions in the util package;
split out the functions into a separate file so CGO_ENABLED=0
works if those functions are never used.

Fixes coreos#171
heyitsanthony pushed a commit to heyitsanthony/go-systemd that referenced this issue Aug 15, 2016
Some projects don't need the CGO functions in the util package;
split out the functions into a separate file so CGO_ENABLED=0
works if those functions are never used.

Fixes coreos#171
heyitsanthony pushed a commit to heyitsanthony/go-systemd that referenced this issue Aug 15, 2016
Some projects don't need the CGO functions in the util package;
split out the functions into a separate file so CGO_ENABLED=0
works if those functions are never used.

Fixes coreos#171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants