Skip to content

anapsix/worker-in-a-box

Repository files navigation

worker-in-a-box

NOTE: please see Cloudflare's official workerd for running Cloudflare Workers in local dev environment.

Cloudflare Workers are awesome! But what if you want to run workers in your dev environment, or in your own environment? Well, there is a great project (albeit, unmaintained) from Dollar Shave Club - cloudworker, which allows you to run Cloudflare Workers locally. Let's combine it with Nginx Unit, and run it in a Docker container.

Using an image built based on this repo as source in FROM directive, one can create a functional worker-in-a-box.

Usage

  1. Initialize submodule
git submodule init
git submodule update
  1. Build worker-in-a-box image
docker build -t worker .
  1. Use the image to package your Cloudflare Worker (see hello-world example)
# Dockerfile
FROM worker
docker build -t hello-world .
  1. Launch it
docker run -it --rm -p 8080:8080 hello-world
  1. Access it via http://localhost:8080

TODO

  • patch cloudworker to support Redis as KV
  • improve lauch_worker.js script to work with KV bindings
  • improve ONBUILD process

About

Cloudflare Workers with Cloudworker and Nginx Unit

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published