weaveworks / scope

Monitoring, visualisation & management for Docker & Kubernetes
https://www.weave.works/oss/scope/
Apache License 2.0
5.84k stars 708 forks source link

Require image for ARM64 architecture #3830

Open odidev opened 3 years ago

odidev commented 3 years ago

@bboreham As mentioned in this comment, I am working on building and pushing scope images. I have created a new dockerfile for scope and did the changes in order to use buildx in Circle-CI to build and push the image for both platforms to dockerhub. But the issue here is the docker image for cloud agent also needs to be built for arm64 platforms. I did the changes but was not able to build the scope binary using command time env GOGC=off CGO_ENABLED=1 go build -mod vendor -ldflags "-extldflags \"-static\" -X main.version="${VERSION}" -s -w" -tags 'netgo unsafe' -o scope ./prog and getting the below error:

[linux/amd64 builder 6/8] RUN time env GOGC=off CGO_ENABLED=1  go build -mod vendor -ldflags "-extldflags "-static" -X main.version="cfd945255" -s -w" -tags 'netgo unsafe' -o scope ./prog:
#25 126.1 # github.com/iovisor/gobpf/elf
#25 126.1 vendor/github.com/iovisor/gobpf/elf/elf.go:51:10: fatal error: linux/unistd.h: No such file or directory
#25 126.1    51 | #include <linux/unistd.h>
#25 126.1       |          ^~~~~~~~~~~~~~~~
#25 126.1 compilation terminated.
#25 145.4 Command exited with non-zero status 2

Changes done: https://github.com/odidev/scope/commit/69ec3a89f4c338c5696b6520ba2866cd05da593e Circle-CI logs: https://app.circleci.com/pipelines/github/odidev/scope/2/workflows/4402deee-847e-4d5e-9618-cadd12719e49/jobs/4

Can I get any suggestions on the above issue?

bboreham commented 3 years ago

That's a 3rd-party package, so you could try asking in their repo. I guess for the current Scope build that header is installed by one of the apt-get lines.

I note in your log that the line that failed says linux/amd64, is it really the arm build that failed?

(also I would suggest you try to make buildx log in a more linear fashion for CI)

odidev commented 3 years ago

I have successfully built and pushed the scope image to dockerhub using buildx in circle-ci. I have used odidev/cloud-agent image in “Dockerfile.scope_multiarch'' as current weaveworks/cloud-agent image does not have arm64 tag.

Commit Link - https://github.com/odidev/scope/commit/ab2609525c5d39ad66771ecdf5b26009b7097f4d Circle-ci Link - https://app.circleci.com/pipelines/github/odidev/scope/5/workflows/858ec7ba-257b-4a21-abd7-12b979dd285b/jobs/27 Dockerhub Link for scope - https://hub.docker.com/repository/docker/odidev/scope Dockerhub Link for cloud-agent - https://hub.docker.com/repository/docker/odidev/cloud-agent

If the changes look good I am happy to raise the PR.

bboreham commented 3 years ago

Thanks for looking further at this.

We currently have a 2-stage build with the Dockerfile in backend used as builder. You appear to have introduced a different 2-stage build, without changing the above.

Can you rationalise this so there is only one build mechanism? I don't want to have to maintain two similar sets of code.

Note changes under way at #3833.

odidev commented 3 years ago

I have used a multi-stage build in dockerfiles as the image will contain only the required binaries and files and it will be of less size. So, I have built the binaries in one stage and in the second stage just copied the binaries. Can you point me on what part of the changes need to be updated as I have checked backend dockerfile and multi-stage has not been used in the same?

Please let me know if I misunderstood anything here. Thanks.

bboreham commented 3 years ago

Although it is not using Docker's 2-stage syntax, the backend image is effectively used in the same way. What needs to change is we need to end up with only one place where we install gcc and pcap, and anything like that.

https://github.com/odidev/scope/commit/ab2609525c5d39ad66771ecdf5b26009b7097f4d#diff-e1add86e962a42a5ca0b3b0cb7cdb54a80b4dc76e8f0650caa4d86587ecf83d1R5 https://github.com/weaveworks/scope/blob/053afd56895966c830ec29f7666c73b5d0bd9e9f/backend/Dockerfile#L7

It may be that the current build image ends up being removed. For instance we could switch to golangci-lint instead of installing separate tools from source.

Separately, having looked more closely, I am confused why your docker/Dockerfile.scope_multiarch uses cloud-agent as builder rather than the Go image.

odidev commented 3 years ago

As per your suggestion, I have modified the files. In docker/Dockerfile.cloud-agent_multiarch file I have used golang-lint as the builder image but still, there was a need to install time and libpcap-dev dependencies.

Commit Link - https://github.com/odidev/scope/commit/a9db29ccc05230ef1f4c8cfdd38ebd30b4274cda Circle-ci Link - https://app.circleci.com/pipelines/github/odidev/scope/9/workflows/769269ef-7292-41a5-a2bf-fd9c01e15e71/jobs/58

Please share your suggestions on this.

bboreham commented 3 years ago

3845 reminded me there is a DNSSnooper which is not built for arm.

I think this was to do with needing C libraries for pcap, which as you say you have included in your build. So it would be good to re-add that feature on arm.

Fixing that is not essential to move forward with this though. Could you open a PR?

odidev commented 3 years ago

Raised PR.

mericano1 commented 1 year ago

any updates on this ?