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

Require image for ARM64 architecture #3830

Open
odidev opened this issue Feb 9, 2021 · 9 comments
Open

Require image for ARM64 architecture #3830

odidev opened this issue Feb 9, 2021 · 9 comments

Comments

@odidev
Copy link

odidev commented Feb 9, 2021

@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: odidev@69ec3a8
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
Copy link
Collaborator

bboreham commented Feb 9, 2021

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
Copy link
Author

odidev commented Feb 15, 2021

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 -
odidev@ab26095
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
Copy link
Collaborator

bboreham commented Apr 4, 2021

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
Copy link
Author

odidev commented Apr 9, 2021

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
Copy link
Collaborator

bboreham commented Apr 9, 2021

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.

odidev@ab26095#diff-e1add86e962a42a5ca0b3b0cb7cdb54a80b4dc76e8f0650caa4d86587ecf83d1R5

apt-get install -y libpcap-dev time file shellcheck git gcc-arm-linux-gnueabihf curl build-essential; \

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
Copy link
Author

odidev commented Apr 14, 2021

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 - odidev@a9db29c
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
Copy link
Collaborator

#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
Copy link
Author

odidev commented Apr 20, 2021

Raised PR.

@mericano1
Copy link

any updates on this ?

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