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

docker images with weed not a dynamic executable #1856

Closed
kmlebedev opened this issue Mar 4, 2021 · 14 comments
Closed

docker images with weed not a dynamic executable #1856

kmlebedev opened this issue Mar 4, 2021 · 14 comments

Comments

@kmlebedev
Copy link
Contributor

Good

cd ../weed; CGO_ENABLED=0 GOOS=linux go build -ldflags "-extldflags -static"
ldd ./weed
not a dynamic executable

Need to fix

docker run -it --entrypoint sh chrislusf/seaweedfs:latest
/ # ldd /usr/bin/weed
/lib/ld-musl-x86_64.so.1: /usr/bin/weed: Not a valid dynamic program
@chrislusf
Copy link
Collaborator

Not clear what is unexpected here.

@kmlebedev
Copy link
Contributor Author

kmlebedev commented Mar 10, 2021

Not clear what is unexpected here.

The weed binary is expected to be compiled as static
But in fact, in the docker image, a weed binary with dynamic dependency
https://github.com/chrislusf/seaweedfs/blob/master/Makefile#L14

@chrislusf
Copy link
Collaborator

what needs changes? Seems all the flags are already in place.

CGO_ENABLED=0 GOOS=linux go build -ldflags "-extldflags -static"

@kmlebedev
Copy link
Contributor Author

what needs changes? Seems all the flags are already in place.

CGO_ENABLED=0 GOOS=linux go build -ldflags "-extldflags -static"

I didn't find it right away. try adding to https://github.com/chrislusf/seaweedfs/blob/master/.github/workflows/release.yml#L37

    env:
      - CGO_ENABLED=0

@chrislusf
Copy link
Collaborator

I didn't find it right away. try adding to https://github.com/chrislusf/seaweedfs/blob/master/.github/workflows/release.yml#L37

    env:
      - CGO_ENABLED=0

@wangyoucao577 how to pass in additional env variables such as CGO_ENABLED?

@chrislusf
Copy link
Collaborator

what needs changes? Seems all the flags are already in place.

CGO_ENABLED=0 GOOS=linux go build -ldflags "-extldflags -static"

I didn't find it right away. try adding to https://github.com/chrislusf/seaweedfs/blob/master/.github/workflows/release.yml#L37

    env:
      - CGO_ENABLED=0

@kmlebedev this is only related to building a dev version, and not used in docker images.

@kmlebedev
Copy link
Contributor Author

kmlebedev commented Mar 10, 2021

this is only related to building a dev version, and not used in docker images.

Then maybe here https://github.com/chrislusf/seaweedfs/blob/master/docker/Dockerfile.go_build#L8

I am a little confused as this is where the release is loaded with github.com
https://github.com/chrislusf/seaweedfs/blob/master/docker/Dockerfile#L18

@chrislusf
Copy link
Collaborator

Where did you find the binary is not static?

@kmlebedev
Copy link
Contributor Author

Where did you find the binary is not static?

on the hub.docker.com

docker pull chrislusf/seaweedfs:2.31
2.31: Pulling from chrislusf/seaweedfs
ba3557a56b15: Already exists
80362092e794: Pull complete
464ae6cea297: Pull complete
bfc12d47eb05: Pull complete
02f445ba7f10: Pull complete
9c8e24856a59: Pull complete
4de7afffb1bb: Pull complete
Digest: sha256:3211f5e09ef49610c8547b1a3918acd6e6a08d29402cb2ca62d80642b12da9d0
Status: Downloaded newer image for chrislusf/seaweedfs:2.31
docker.io/chrislusf/seaweedfs:2.31

docker run -it --entrypoint sh chrislusf/seaweedfs:2.31
/ # ldd /usr/bin/weed
	/lib/ld-musl-x86_64.so.1 (0x7f301a953000)
	libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f301a953000)

@wangyoucao577
Copy link
Contributor

@chrislusf to disable CGO in go-release-action, try add pre_command: export CGO_ENABLED=0.
But this is not an issue since binary can work well in the docker image.

@kmlebedev
Copy link
Contributor Author

kmlebedev commented Mar 11, 2021

CGO_ENABLED

@chrislusf to disable CGO in go-release-action, try add pre_command: export CGO_ENABLED=0.
But this is not an issue since binary can work well in the docker image.

@wangyoucao577
Thanks, in another project I tried to transfer env variables for compile code.
What to do if pre_command is already in use for another command?
go-release-actio prevents two commands from being sent.
https://github.com/kmlebedev/txmlconnector/blob/main/.github/workflows/release.yml#L31

@wangyoucao577
Copy link
Contributor

@kmlebedev It supposed to not prevent. Let me check.

@wangyoucao577
Copy link
Contributor

@kmlebedev try out wangyoucao577/go-release-action@bugfix/mutli-pre-cmd please. I'll merge it a little bit later.

@wangyoucao577
Copy link
Contributor

@kmlebedev
v1.15 will solve the issue for you. Please have a try. Feel free to let me know if any issue.

- name: Go Release Binaries
  uses: wangyoucao577/go-release-action@v1.15

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

No branches or pull requests

3 participants