pygmystack / pygmy

the pygmy stack is a container stack for local development
MIT License
25 stars 13 forks source link

Provide static-linked binaries instead of dynamic ones #328

Closed tobybellwood closed 3 years ago

tobybellwood commented 3 years ago

Is your feature request related to a problem? Please describe. Currently, Go is required to be installed on the host system in order to run Pygmy.

Describe the solution you'd like Pygmy should be completely standalone. This would mean creating static-linked binaries instead of dynamic ones.

(I've got an example I can PR shortly for review)

fubarhouse commented 3 years ago

Go is not at all required for a couple of reasons, however if you have an example I'd be glad to look it over. Go is however very convenient for local development of pygmy.

Send an example my way and I'll check it out.

tobybellwood commented 3 years ago

If I don't build it using a static command - it thinks it needs the musl interpreter?

tobybellwood@pop-os:~/sites/pygmy-go/builds$ ls -al
total 73968
drwxrwxr-x 2 tobybellwood tobybellwood     4096 Jul 19 13:18 .
drwxrwxr-x 9 tobybellwood tobybellwood     4096 Jul 16 14:59 ..
-rw-rw-r-- 1 tobybellwood tobybellwood        0 Oct  8  2020 .gitkeep
-rwxr-xr-x 1 root         root         12654496 Jul 19 13:18 pygmy-go-darwin
-rwxr-xr-x 1 root         root         12316418 Jul 19 13:18 pygmy-go-darwin-arm
-rwxr-xr-x 1 root         root         13212160 Jul 19 13:18 pygmy-go.exe
-rwxr-xr-x 1 root         root         12843530 Jul 19 13:18 pygmy-go-linux
-rwxr-xr-x 1 root         root         11920480 Jul 19 13:18 pygmy-go-linux-arm
-rwxr-xr-x 1 root         root         12778514 Jul 19 13:18 pygmy-go-linux-static
tobybellwood@pop-os:~/sites/pygmy-go/builds$ ./pygmy-go-linux version
bash: ./pygmy-go-linux: No such file or directory
tobybellwood@pop-os:~/sites/pygmy-go/builds$ ./pygmy-go-linux-static version
Pygmy version unidentifiable.
tobybellwood@pop-os:~/sites/pygmy-go/builds$ file pygmy-go-linux
pygmy-go-linux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, Go BuildID=HUk03aGAGqWdyEBB8_-D/RPdIgOzmQjj9kmcfWpN-/JQYB5bBCGyuDvhms9XDw/dJBr7gLePRTYVOqIfZYL, not stripped
tobybellwood@pop-os:~/sites/pygmy-go/builds$ file pygmy-go-linux-static
pygmy-go-linux-static: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=86g9qovY554oeqjq5GV2/Rxs_2-ammr5pyZpUGtvA/JQYB5bBCGyuDvhms9XDw/TXRAllcWUiG23b-YtPOU, not stripped

All i've added is a new build to the Dockerfile RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o pygmy-go-linux-static .

fubarhouse commented 3 years ago

Easy as - I'll make it happen. :+1:

fubarhouse commented 3 years ago

Have a look at 1bd85bde7c7098ab17705d3aced4ebe245fd218f if you can. Feedback would be appreciated - will create a PR shortly.