cloudflared icon indicating copy to clipboard operation
cloudflared copied to clipboard

feat(docker): build docker images with buildkit, add actions

Open initdc opened this issue 2 years ago • 11 comments

hello, I add docker build workflow for cloudflared. I am learning buildx near time, and I feel good.

It may also helpful in your bin distro.

Edit docker tags, actions user token by your own.

I found a problem, user can't run docker with -it, because image FROM scratch but it's useful for cross-compiling.

It may need two kind Dockerfile

check more usage from:

  • https://github.com/initdc/ssh-proxy-by-caddy-l4
  • https://hub.docker.com/r/initdc/cloudflared

initdc avatar Apr 08 '22 09:04 initdc

@initdc I would suggest also adding curl to fix #188 (comment)

COPY that, take a check

initdc avatar May 11 '22 13:05 initdc

It would be really great if this PR was merged. Is anything blocking it?

SayakMukhopadhyay avatar Jun 16 '22 13:06 SayakMukhopadhyay

@initdc can you resolve conflicts, +1 for arm platform?

usma0118 avatar Jun 22 '22 07:06 usma0118

@initdc can you resolve conflicts, +1 for arm platform?

I am not sue keep which part, do we need these ARG for building bin files?

initdc avatar Jun 22 '22 12:06 initdc

@sudarshan-reddy pinging you since you are assigned to the related issue #628. This PR releases the container as a Github actions workflow but I haven't seen anything regarding how you folks release the containers right now. The only thing I have seen is https://github.com/cloudflare/cloudflared/blob/135c8e6d13663d2aa2d3c9169cde0cfc1e6e2062/Makefile#L131-L133

If you folks are using some internal tooling to run make container somehow then that needs to be adapted. Else, instead of creating an action, this PR can be modified to change the Makefile itself so that it runs docker buildx and not docker build (example is in https://github.com/SayakMukhopadhyay/cloudflared-docker-multiarch/tree/docker-mp).

As seen in the linked issue, many people have started using their own images, including me but this leads to increased fragmentation and possible security holes. Since this PR is currently blocked due to a conflict, it would be great if someone from the cloudflare team would shed some light as to how to get this PR merged, as is or with some changes.

SayakMukhopadhyay avatar Jun 29 '22 06:06 SayakMukhopadhyay

I apologize for the ping in advance @usma0118 , but is there anything blocking this PR from being merged. Would you prefer a fresh PR on this, in which case I would be willing to provide one. Also, please do read my previous comment as I would like some clarification regarding what CI approach the maintainers would prefer.

SayakMukhopadhyay avatar Jul 12 '22 07:07 SayakMukhopadhyay

I apologize for the stagnation in checking this PR. This is great work. The delay is because I'm currently evaluating the maintainability of putting this build process in Cloudflare's internal CI vs on GH. I'll have more news soon!

sudarshan-reddy avatar Jul 18 '22 16:07 sudarshan-reddy

I can confirm that I was able to use this PR to run a Cloudflared tunnel in Docker on my (arm64) Raspberry Pi. Great stuff - would love to see this merged!

scubbo avatar Jul 20 '22 16:07 scubbo

Check the latest workflow. https://github.com/initdc/golang-project-workflow

initdc avatar Jul 23 '22 10:07 initdc

@initdc Any particular reason why you are using ruby to build for multiple containers? Docker buildkit action should be able to do it by itself.

SayakMukhopadhyay avatar Jul 23 '22 10:07 SayakMukhopadhyay

@initdc Any particular reason why you are using ruby to build for multiple containers? Docker buildkit action should be able to do it by itself.

Ruby is more easy to understand, easy to exec CMD compare with JS. Who want use $1 $# $@ in 2022, moreover you need quote them. bash and makefile, bad ass.

docker buildx just did one thing which combine multi arch images as one tag.

initdc avatar Jul 23 '22 12:07 initdc

I apologize for the stagnation in checking this PR. This is great work. The delay is because I'm currently evaluating the maintainability of putting this build process in Cloudflare's internal CI vs on GH. I'll have more news soon!

Thanks for all the effort here. We finally deliberated on this and decided to keep this build on our internal CI. This is because we can take advantage of metrics and support from more teams to make sure we keep this flow maintained.

I'm closing this PR but this work was very instrumental in Cloudflare getting this image out. So thank you so much all of you for making this happen.

We now have an arm64 image on Dockerhub. Feel free to test/use it and report any bugs or suggestions.

sudarshan-reddy avatar Aug 16 '22 15:08 sudarshan-reddy

I can confirm that the arm64 cloudflared image is working perfectly on my setup. Thanks a ton for this!

scubbo avatar Aug 19 '22 06:08 scubbo