Skip to content
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

Add command in Makefile to get a completly static binary #458

Closed
wants to merge 1 commit into from

Conversation

titilambert
Copy link
Contributor

No description provided.

@@ -15,6 +15,11 @@ build:
"-X main.Version=$(VERSION)" \
./cmd/telegraf/telegraf.go

build-for-docker:
GO_ENABLED=0 GOOS=linux go build -o telegraf -ldflags \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean CGO_ENABLED=0?

Could you also explain why this is necessary? I believe some of the linux system plugins rely on CGO and some of them may not function with this flag.

@titilambert
Copy link
Contributor Author

@sparrc Thanks ! Yeah it's CGO_ENABLED=0 :)
My use case: I need to use telegraf in a container to query an other container (these two containers are in the same K8S pod). So I want the telegraf container really small, with this option I can get a 25Mo container :)

@sparrc
Copy link
Contributor

sparrc commented Dec 22, 2015

@titilambert and these are linux containers that don't have access to libc? I'm curious why exactly they can't use binaries that use CGO

@titilambert
Copy link
Contributor Author

Hum... Maybe I missed something with docker ??? @sparrc
If build telegraf without CGO_ENABLED=0, I get an error:

1 . Here my docker file:

  FROM scratch
  COPY ./telegraf /

2 . I build it

  docker build -t telegraf .

3 . I run it

docker run telegraf /telegraf
WARNING: Your kernel does not support memory swappiness capabilities, memory swappiness discarded.
no such file or directory
Error response from daemon: Cannot start container 1c94b30e035b517381637732067c05c0f472ed26490db5a4a4f714f6530590f4: [8] System error: no such file or directory

Did I miss something ?

I don't have this error with CGO_ENABLED=0

@sparrc
Copy link
Contributor

sparrc commented Feb 3, 2016

@titilambert do you still need this PR merged?

@titilambert
Copy link
Contributor Author

@sparrc yes ! I use telegraf in a "FROM strach" container. But are you agree with this "feature" ?

@sparrc sparrc closed this in 35150ca Feb 5, 2016
@sparrc
Copy link
Contributor

sparrc commented Feb 5, 2016

yes, sorry it took me so long to get to this

@titilambert
Copy link
Contributor Author

@sparrc Thanks for merge this one !
Will you release this static binary of telegraf for each version ?
BTW how can I get something like this https://pbs.twimg.com/media/CXlgQZ7UoAE3AMZ.jpg ?

Thanks !

@titilambert titilambert deleted the static branch February 20, 2016 05:19
geodimm pushed a commit to miketonks/telegraf that referenced this pull request Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants