diff --git a/BUILDING.md b/BUILDING.md index 9594fdfe4..327d0aaf8 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -43,6 +43,20 @@ You can move them in your global path with: sudo make install ``` +### Static binaries + +You can build static binaries by providing a few variables to `make`: + +```sudo +make EXTRA_FLAGS="-buildmode pie" \ + EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' \ + BUILDTAGS="static_build" +``` + +Note that + - static build is discouraged + - static containerd binary does not support plugins loading + ## Via Docker Container ### Build containerd diff --git a/plugin/plugin_go18.go b/plugin/plugin_go18.go index d9101246e..eee0e3fdb 100644 --- a/plugin/plugin_go18.go +++ b/plugin/plugin_go18.go @@ -1,4 +1,4 @@ -// +build go1.8,!windows,amd64 +// +build go1.8,!windows,amd64,!static_build package plugin diff --git a/plugin/plugin_other.go b/plugin/plugin_other.go index 21a457040..180917af8 100644 --- a/plugin/plugin_other.go +++ b/plugin/plugin_other.go @@ -1,4 +1,4 @@ -// +build !go1.8 windows !amd64 +// +build !go1.8 windows !amd64 static_build package plugin