|
1 | 1 | # Dev Setup |
2 | 2 |
|
3 | | -Guide to setting up this worker for development. |
| 3 | +Documentation on how to run the Release Worker locally. |
4 | 4 |
|
5 | | -## Have Node Installed |
| 5 | +## Steps |
6 | 6 |
|
7 | | -Node needs to be installed for the thing that serves Node downloads (latest LTS/even numbered major recommended) |
| 7 | +### 1. Prepare environment |
8 | 8 |
|
9 | | -## Install Dependencies |
| 9 | +Read and follow the [Getting Started](../CONTRIBUTING.md) guide to get your |
| 10 | +local environment setup. |
10 | 11 |
|
11 | | -Run `npm install` |
| 12 | +### 2. Setup your Cloudflare account |
12 | 13 |
|
13 | | -## Testing |
| 14 | +Currently we run the worker in [remote mode](https://developers.cloudflare.com/workers/testing/local-development/#develop-using-remote-resources-and-bindings) as there isn't a nice way to |
| 15 | +locally populate an R2 bucket. This means that, to run the Release Worker |
| 16 | +locally, you must have a Cloudflare account that has an R2 bucket named |
| 17 | +`dist-prod`. You will also need to populate the bucket yourself. |
14 | 18 |
|
15 | | -To run unit tests, `npm run test:unit`. To run e2e (end-to-end) tests, `npm run test:e2e`. |
| 19 | +Both of these will hopefully change in the future to make running the Release |
| 20 | +Worker easier. |
16 | 21 |
|
17 | | -See the [/test](../tests/) folder for more info on testing. |
| 22 | +### 3. Create secrets for directory listings |
18 | 23 |
|
19 | | -## Running Locally |
| 24 | +This step is optional but recommended. |
20 | 25 |
|
21 | | -Spin up a Workerd instance on your machine that serves this worker |
| 26 | +The Release Worker uses R2's S3 API for directory listings. In order for |
| 27 | +directory listings to work, you need to make an R2 API key for your `dist-prod` |
| 28 | +bucket and provide it to the worker. |
22 | 29 |
|
23 | | -### Login to Cloudflare Dash From Wrangler CLI |
| 30 | +Generating the API key can be done through the Cloudflare dashboard |
| 31 | +[here](https://dash.cloudflare.com/?account=/r2/api-tokens). |
24 | 32 |
|
25 | | -Run `wrangler login` |
| 33 | +Then, make a `.dev.vars` file in the root of this repository with the following: |
26 | 34 |
|
27 | | -### R2 Bucket |
| 35 | +``` |
| 36 | +S3_ACCESS_KEY_ID=<your access key id> |
| 37 | +S3_ACCESS_KEY_SECRET=<your access key secret> |
| 38 | +``` |
28 | 39 |
|
29 | | -Create a R2 bucket named `dist-prod`. This is the bucket that the worker read from. It will either need to have a copy of Node's dist folder in it or something mimicing the folder there. |
| 40 | +### 4. Run the worker |
30 | 41 |
|
31 | | -### Starting the Local Server |
32 | | - |
33 | | -Run `npm start`. This starts a Workerd instance in remote mode. |
| 42 | +Start the worker locally with `npm start`. You may be prompted to log into |
| 43 | +your Cloudflare account. |
0 commit comments