workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Dockerize wrangler

Open mrpatrick opened this issue 5 years ago • 22 comments

Suggestion

  • It would be great to have a dockerized version of this program that is self-contained
  • include an option to for build-required files (i.e. cache the template requirements in the image so they don't have to be downloaded everytime you call build
  • include node version option

mrpatrick avatar Jul 22 '19 14:07 mrpatrick

Hi @mrpatrick! Thanks for submitting a feature request + suggested PR :).

Before we consider adding a new feature to Wrangler, we need to think about how it fits into the Wrangler user experience. A couple of questions with respect to your feature:

  1. How does this dockerized version of Wrangler improve Wrangler setup and usage? What pain points does it address?
  2. What is the intended workflow for using this dockerized Wrangler binary?
  3. How would this dockerized distribution of wrangler be distributed? Would folks need to always build the container themself? Would this be an image folks would use from the docker registry? How will the dockerized wrangler binary be maintained and updated with new point releases? (Maintaining a docker registry binary would be an additional burden on the Wrangler maintainers if there's not a huge benefit to using wrangler via docker anyways).

Again, thanks for reaching out to us, and we're looking forward to hear more of your rationale for this feature.

gabbifish avatar Jul 22 '19 22:07 gabbifish

Hi @gabbifish - thanks for considering. See inline below

  1. How does this dockerized version of Wrangler improve Wrangler setup and usage? What pain points does it address?

Doesn't rely on npm/node (or knowledge on using node/npm), os libraries, software updates, etc. You just need docker - that's it. This makes "installing" easy (i.e. I can use this program even though I don't have node/npm on my laptop). It always makes updates easier and doesn't rely on 3rd party libraries / software other than docker (i.e. no conflicts / issues with updates). it's fully self contained. Docker is well established platform and most CLI's and services have an official docker version. This would help wrangler become more widely accepted and provide greater availability / visibility.

  1. What is the intended workflow for using this dockerized Wrangler binary?

Suggested workflow is documented here: https://github.com/cloudflare/wrangler/pull/338

This is of course how I'm using it and others may have better suggestions / improvements to this.

How would this dockerized distribution of wrangler be distributed? Would folks need to always build the container themself? Would this be an image folks would use from the docker registry?

I would suggest providing both methods (as keeping with docker best practices and standards). If you take a look at my PR, it's just adding 2 files: Dockerfile, .dockerignore to the repo. That allows other to build the image as they see fit as well as provide an docker image via docker registry like I'm currently doing via our company repo:

https://hub.docker.com/r/avatarnewyork/wrangler

How will the dockerized wrangler binary be maintained and updated with new point releases? (Maintaining a docker registry binary would be an additional burden on the Wrangler maintainers if there's not a huge benefit to using wrangler via docker anyways).

I would suggest having an official wrangler docker repo (or maybe under cloudflare's docker repo)? Of course it's not required but would give it more visibility to the community and make it easier to find / use. In regards to image builds/maint, I would suggest integrating the build within your existing CI workflow (or, if that is too much of a pain, a less ideal option would be to kick off an automated build on the docker registry. This of course, wouldn't allow you to run any tests though, which could be done as part of your CI process). If you prefer NOT to host your own binary / image, you could just provide the dockerfile to allow others to build, but won't have the same impact.

mrpatrick avatar Aug 07 '19 17:08 mrpatrick

Hi @mrpatrick! Thanks so much for being patient! The maintainer team has discussed maintaining a dockerized solution. It is definitely on our roadmap for the future--I'd be keen to experiment with GitHub actions to see how we could accomplish automated publishing in as clean a fashion as possible. Do you mind if we keep your PR on ice for now as we think about how to possibly integrate this with new infrastructure like GitHub actions and how this fits into our milestone planning?

In the meantime, you're also welcome to share your dockerized implementation around with other Wrangler users!

gabbifish avatar Aug 26 '19 17:08 gabbifish

Hi @gabbifish - glad it's on the roadmap and all sounds good. Thanks!

Pat

mrpatrick avatar Aug 26 '19 19:08 mrpatrick

I agree wholeheartedly with putting wrangler into docker, because not just npm but also rustup could be configured so that the user doesn't have to install the lot on the local machine.

However, I don't think the preview command would work from inside the docker container. So may I suggest using the normal wrangler install, and it asking if the user wants to user docker or install rust and/or npm modules locally (if docker is detected)? Then, the wrapper command can call build inside the docker container but call preview from outside the container.

aqueenan avatar Aug 30 '19 03:08 aqueenan

It would be really good to have it dockerized. I would like to automate the deployment of my workers using Bitbucket Pipelines and having it dockerized would help to just use it in a bitbucket-pipelines.yml instead of maintain my own container, rely on third-party containers or install NPM package for every deployment.

I'm looking forward to an official image.

lisotton avatar Feb 26 '20 20:02 lisotton

Gitlab also uses docker images for its ci - using Wrangler would be much easier with a docker image that could just be pulled from Docker Hub.

Albitos avatar Mar 26 '20 20:03 Albitos

This would be really, really useful. I was loving the experience until I tried getting wrangler to work on Circle CI and then ran into a brick wall. The only way you can do a global install in a circle CI docker image is by using sudo, which doesn't install wrangler properly.

If anyone other than cloudflare built wrangler, I would have dropped it already, but I'm really keen to use this so I'm building a custom docker image for use in circle CI. An official wrangler image with node would have made all of this a non issue

abury avatar Apr 01 '20 22:04 abury

What's the state of this issue? This would be great to insert the publish step on a pipeline.

Serrvosky avatar Jul 07 '20 12:07 Serrvosky

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 05 '20 14:09 stale[bot]

I still think that this ticket is very important!

lisotton avatar Sep 06 '20 09:09 lisotton

Leaving my support for this, I would love to have an official wrangler docker image available. I'd really like to use this for a gitlab runner.

Disgruntled avatar Sep 17 '20 23:09 Disgruntled

Or if the cloudflare team is not willing to provide support to this, at least inform that there is a community-project providing a docker image (https://github.com/avatarnewyork/wrangler)

oliverpool avatar Sep 18 '20 06:09 oliverpool

In the meantime: for those who want to deploy with Github Actions, there is cloudflare/wrangler-action.

Electroid avatar Sep 18 '20 16:09 Electroid

I'm a little surprised not to find official support for a Docker image. https://hub.docker.com/r/avatarnewyork/wrangler sounds like it will suffice, but can understand why an official image might not currently exist, if I'm honest.

dynamite-ready avatar Dec 12 '20 13:12 dynamite-ready

Adding another user case with my upvote. I want to follow the Cloudflare workers Rust tutorials, and having to install all the node, npm, etc. especially not being a JavaScript expert looks daunting to me and raises the concern of breaking my local, since I'm not on a recent distro and adding third party repos can be risky.

If producing a pull-able image hinders delivery, just n officially sanctioned Dockerfile in the repo would do, since anyone will be able to docker build -t wrangler github.com/cloudflare/wrangler with confidence.

@gabbifish (or anyone else at Cloudflare): Do you have any news about progress/roadmap on this?

pataquets avatar Oct 08 '21 16:10 pataquets

🙏 this would be really helpful for CI. especially as images like avatarnewyork/wrangler are outdated

vojkny avatar Feb 11 '22 22:02 vojkny

Adding another use case with my upvote. Having an official Docker image for Wrangler is essential for automating our CICD system

JubbaSmail avatar Feb 14 '22 11:02 JubbaSmail

I agree that an official image would be amazing. I'm using Wrangler with Bitbucket Pipelines and I had to use the official Node image and run the following:

script:
  - npm -g config set user root
  - npm install -g @cloudflare/wrangler
  - wrangler publish

I know that installing the library in every deployment could be a problem, but it is taking 4s to do it, so not a big problem.

lisotton avatar Feb 14 '22 11:02 lisotton

Created a Docker example for Windows using Nano Server.

https://github.com/michaellwest/docker-wrangler-node

michaellwest avatar May 23 '22 17:05 michaellwest

Transferred from Wrangler 1 repo. I think there appears to still be interest in having a Docker image, even for Wrangler 2. Notably @michaellwest's demo at https://github.com/michaellwest/docker-wrangler-node shows that it can be achieved relatively easily. That being said, perhaps it would be enough for us to provide good CI setup examples (maybe prepackages GitHub Actions and CircleCI Orbs) instead?

petebacondarwin avatar Jun 21 '22 08:06 petebacondarwin

Yeah, I still want this, having been following this issue for years. As you said, it should be relatively easy to create a Dockerfile for this. Here's what I'm using personally:

FROM node
RUN npm install -g wrangler
ENTRYPOINT ["wrangler"]

Nothing remarkable, really. The sole reason why I want this is not due to the difficulty, but I want some authoritative sources of the Docker images I use daily.

barosl avatar Jun 21 '22 11:06 barosl

We don't currently have plans to create an official Docker image for wrangler. @barosl's suggestion above seems to cover the bases. Closing for now.

RamIdeas avatar Jul 31 '23 15:07 RamIdeas