{"id":24617780,"url":"https://github.com/jacoblincool/workerd-docker","last_synced_at":"2025-05-07T05:42:01.180Z","repository":{"id":225546198,"uuid":"765880227","full_name":"JacobLinCool/workerd-docker","owner":"JacobLinCool","description":"This minimalist Docker image allows you to run a Cloudflare Worker inside a Docker container, offering a simple solution for deploying and testing your worker on your infrastructure.","archived":false,"fork":false,"pushed_at":"2024-03-03T12:07:55.000Z","size":5,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T06:51:12.456Z","etag":null,"topics":["cloudflare-workers","docker","self-hosted","workerd"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/jacoblincool/workerd","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JacobLinCool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-01T20:01:42.000Z","updated_at":"2025-03-12T17:42:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"e6728197-2e8b-45fa-a83e-0104faff8af8","html_url":"https://github.com/JacobLinCool/workerd-docker","commit_stats":null,"previous_names":["jacoblincool/workerd-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fworkerd-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fworkerd-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fworkerd-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fworkerd-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobLinCool","download_url":"https://codeload.github.com/JacobLinCool/workerd-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252823662,"owners_count":21809707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-workers","docker","self-hosted","workerd"],"created_at":"2025-01-24T23:40:54.731Z","updated_at":"2025-05-07T05:42:01.172Z","avatar_url":"https://github.com/JacobLinCool.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Workerd Docker Image\n\nSupported Architectures: `amd64`, `arm64`\n\nThis minimalist Docker image allows you to run a Cloudflare Worker inside a Docker container, offering a simple solution for deploying and testing your worker on your infrastructure.\n\n- [Docker Hub](https://hub.docker.com/r/jacoblincool/workerd)\n- [GitHub Repository](https://github.com/JacobLinCool/workerd-docker)\n\n## Quick Start Guide\n\n### Selflare\n\nThe fastest way to get your Cloudflare Worker running as a Docker container is to use [Selflare](https://github.com/JacobLinCool/selflare), which also supports KV, D1, R2, DO, and Cache API out of the box.\n\n```bash\nnpm i -g selflare  # Install Selflare\nselflare compile   # Compile yours worker to Cap'n Proto\nselflare docker    # Generate Dockerfile and docker-compose.yml\ndocker compose up  # Run the worker\n```\n\nYou can now access your worker at `http://localhost:8080`!\n\n### Manual Setup\n\nIf you prefer to set up the Cap'n Proto manually, follow the steps below.\n\n#### 1. Prepare Your Worker\n\nFirst, build your worker with Wrangler by running the following command in your project directory:\n\n```sh\nwrangler deploy --dry-run --outdir .wrangler/dist\n```\n\nThis command compiles your worker and outputs the result script to `.wrangler/dist/index.js`.\n\n#### 2. Configure `worker.capnp`\n\nNext, create a `worker.capnp` file in the same directory as your `wrangler.toml`. This file is used to configure the Workerd runtime. Below is a template you can start with:\n\n```capnp\nusing Workerd = import \"/workerd/workerd.capnp\";\n\nconst config :Workerd.Config = (\n    services = [\n        (name = \"main\", worker = .worker),\n    ],\n    sockets = [\n        (service = \"main\", name = \"http\", address = \"*:8080\", http = ()),\n    ]\n);\n\nconst worker :Workerd.Worker = (\n    modules = [\n        (name = \"worker\", esModule = embed \".wrangler/dist/index.js\"),\n    ],\n    compatibilityDate = \"2024-02-19\",\n);\n```\n\nFor detailed information on configuring `worker.capnp`, refer to the [Workerd Repository](https://github.com/cloudflare/workerd/tree/main?tab=readme-ov-file#configuring-workerd).\n\n#### 3. Run the Docker Image\n\nWith your worker built and configured, you're ready to run it inside a Docker container. Execute the following command:\n\n```sh\ndocker run -v $(pwd):/worker -p 8080:8080 jacoblincool/workerd\n```\n\nThis command mounts your current directory to the `/worker` directory inside the container and forwards port 8080 to your local machine.\n\n#### Accessing Your Worker\n\nAfter starting the Docker container, your worker will be accessible at `http://localhost:8080`.\n\n## Use as a Base Image\n\nYou can also use this image as a base image for your own worker. Below is an example `Dockerfile`:\n\n```Dockerfile\nFROM jacoblincool/workerd\n\nCOPY worker.capnp worker.capnp\nCOPY other-file-like-your-worker.js other-file-like-your-worker.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fworkerd-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoblincool%2Fworkerd-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fworkerd-docker/lists"}