Skip to content

Commit d6e361e

Browse files
add readmes for cloudflare and sentry (#129)
1 parent 56c110d commit d6e361e

20 files changed

+103
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
1. [Sign up for Cloudflare](https://www.cloudflare.com/) (they have a free tier)
2+
3+
2. Create a Pages app to host the React client. From the Workers & Pages screen, choose "Create".
4+
![](./img/1%20-%20create%20pages.jpg)
5+
6+
3. Select the "Pages" tab and click "Upload assets" from the "Create using direct upload" section.
7+
![](./img/2%20-%20direct%20upload.jpg)
8+
9+
4. Name your app and click "Create". Note: You do not need to upload any assets and click "Deploy". The Wrangler CLI and GitHub actions will take care of that later.
10+
11+
![](./img/3a%20-%20name%20project.jpg)
12+
13+
5. Each time you add an app, you will see it appear in your "Workers & Pages" Overview:
14+
![](./img/4%20-%20dashboard.jpg)
15+
16+
6. Add the following variables under "Variables and Secrets" so that the build command can run in the correct environment:
17+
| Type | Name | Value |
18+
| --- | --- | --- |
19+
| Plaintext | NODE_VERSION | 22.9.0 |
20+
| Plaintext | PNPM_VERSION | 9 |
21+
22+
7. Create a Workers app to host the prod server. From the Workers & Pages Overview page, click "Create" (like step 2), and then from the "Workers" tab, click "Create Worker".
23+
![](./img/7%20-%20create%20worker.jpg)
24+
25+
8. Name your worker and click "Deploy". Note: Ignore the `worker.js` code, as it will be overwritten by our app when we run our deploy script.
26+
![](./img/8%20-%20name%20worker%20and%20deploy.jpg)
27+
28+
9. Add a KV namespace for your prod server storage. Navigate to Workers & Pages - KV, and click "Create a namespace".
29+
![](./img/9%20-%20create%20namespace.jpg)
30+
31+
10. Enter a name for your prod server kv namespace, and click "Add".
32+
![](./img/10%20-%20add%20namespace.jpg)
33+
34+
11. Repeat steps 7-10 for your stage server and kv storage. Note: It might be useful to use suffix `-stage` in your naming.
35+
36+
12. On the right hand side of the Workers & Pages Overview screen, you can find your Account ID, as well as a link to "Manage API tokens":
37+
![](./img/11%20-%20account%20id.jpg)
38+
39+
13. Create an API token for "Edit Cloudflare Workers", using the provided template.
40+
![](./img/12%20-%20edit%20workers%20token.jpg)
41+
42+
14. Add your Cloudflare API Token and Account ID in [.env](../.env). This will enable the Wrangler CLI to deploy the app locally.
43+
44+
15. Add your Cloudflare API Token and Account ID to your repository secrets in GitHub. This will enable deploy from GitHub actions.
45+
![](./img/13%20-%20gh%20vars.jpg)
46+
47+
16. Configure `ENV` and `getServerUrl` in [client/src/config.ts](../client/src/config.ts). Note: This is just a suggestion, and you may choose another method of determining your app's runtime environment.
48+
49+
17. Update [server/wrangler.toml](../server/wrangler.toml) with your app names and IDs. Eg:
50+
51+
```diff
52+
[env.stage]
53+
- name = "todo-rename-stage"
54+
+ name = "my-app-stage"
55+
workers_dev = true
56+
- vars = { ALLOWED_HOST = "todo:rename to stage host", ENV = "stage" }
57+
+ vars = { ALLOWED_HOST = "my-app-stage.pages.dev", ENV = "stage" }
58+
[[env.stage.kv_namespaces]]
59+
binding = "DB"
60+
- id = "e0c5eee53ed34ff69c4d8303f818adca"
61+
+ id = "fThh47jB971c4GP452h75cP7jqE499mL"
62+
```
63+
64+
18. Update the deploy scripts in [client/package.json](../client/package.json) to use your project name. Note: Pages allows a "Preview" branch, for all branches besides main. We use the same app name but provide `--branch "stage"` for our staging branch:
65+
66+
```diff
67+
- "deploy:stage": "pnpm wrangler pages deploy ./dist --project-name todo-rename --branch \"stage\"...,
68+
+ "deploy:stage": "pnpm wrangler pages deploy ./dist --project-name my-app --branch \"stage\"...,
69+
- "deploy:prod": "pnpm wrangler pages deploy ./dist --project-name todo-rename",
70+
+ "deploy:prod": "pnpm wrangler pages deploy ./dist --project-name my-app",
71+
```
47.6 KB
Loading
43.3 KB
Loading
15.4 KB
Loading
85.3 KB
Loading
104 KB
Loading
105 KB
Loading
46.7 KB
Loading
21 KB
Loading
60.9 KB
Loading

0 commit comments

Comments
 (0)