Skip to content

Commit 4d4559d

Browse files
committed
Refine deployment documentation
1 parent 267ab66 commit 4d4559d

1 file changed

Lines changed: 32 additions & 43 deletions

File tree

docs/DEPLOYMENT.md

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,55 @@ This guide explains how to deploy the Evolution Simulation to Cloudflare Pages.
44

55
## Prerequisites
66

7-
1. **Cloudflare Account**: Sign up at [cloudflare.com](https://cloudflare.com)
8-
2. **Wrangler CLI**: Install the Cloudflare Workers/Pages CLI
9-
3. **Rust Toolchain**: Nightly toolchain with WASM support (see README.md)
7+
1. **Cloudflare Account**: [Sign up](https://cloudflare.com)
8+
2. **Wrangler CLI**: `npm install -g wrangler`
9+
3. **Rust Toolchain**: `rustup default nightly-2024-08-02 && rustup target add wasm32-unknown-unknown`
1010

11-
## Deployment Steps
11+
## One-Command Deployment
1212

13-
### 1. Install Dependencies
13+
The easiest way to deploy is using the npm script which handles building and deploying:
1414

1515
```bash
16-
npm install
17-
```
18-
19-
### 2. Login to Cloudflare
20-
21-
```bash
22-
npx wrangler login
23-
```
24-
25-
### 3. Build the Project
26-
27-
```bash
28-
npm run build:web
16+
npm run deploy
2917
```
3018

31-
This commands compiles the Rust code to WebAssembly and places the output in the `pkg/` directory.
19+
This command runs `build:web` (compiling Rust to WASM) and then `wrangler pages deploy`.
3220

33-
### 4. Deploy to Cloudflare Pages
21+
## Manual Steps
3422

35-
```bash
36-
# Deploy to production
37-
npm run deploy
23+
If you prefer to run steps individually:
3824

39-
# Or manually:
40-
npx wrangler pages deploy web --project-name evo
41-
```
25+
1. **Build Web Assembly**:
26+
```bash
27+
npm run build:web
28+
```
29+
*Output*: Generates `pkg/` and ensures `web/pkg/` contains the latest WASM.
4230

43-
This uploads the `web/` directory (which includes the index.html, CSS, JS, and the generated WASM in `web/pkg/`) to Cloudflare Pages.
31+
2. **Deploy to Pages**:
32+
```bash
33+
npx wrangler pages deploy web --project-name evo
34+
```
4435

45-
## Local Development
36+
## Local Testing
4637

47-
Test the Pages build locally:
38+
To simulate the exact Cloudflare environment locally:
4839

4940
```bash
5041
npm run dev:worker
5142
```
43+
*Note: This uses `wrangler pages dev` which respects the `_headers` file.*
5244

53-
This builds the project and starts a local Pages server (using `wrangler pages dev`).
54-
55-
## Configuration
56-
57-
### COOP/COEP Headers regarding SharedArrayBuffer
58-
59-
The simulation uses `SharedArrayBuffer` for parallel processing (via `rayon`). This requires specific security headers to be served:
60-
61-
- `Cross-Origin-Opener-Policy: same-origin`
62-
- `Cross-Origin-Embedder-Policy: require-corp`
45+
## Critical Configuration: SharedArrayBuffer
6346

64-
These are configured in the `web/_headers` file, which Cloudflare Pages uses to apply headers.
47+
This project uses multi-threading (`rayon`), which requires `SharedArrayBuffer`. This feature is only available in secure contexts with specific headers:
6548

66-
## Troubleshooting
49+
- **Config File**: `web/_headers`
50+
- **Required Headers**:
51+
```
52+
Cross-Origin-Opener-Policy: same-origin
53+
Cross-Origin-Embedder-Policy: require-corp
54+
```
6755

68-
### "SharedArrayBuffer is not defined"
69-
If you see this error in the browser console, it means the COOP/COEP headers are missing. Ensure `web/_headers` exists and is being deployed.
56+
**Troubleshooting:**
57+
- **Error**: "SharedArrayBuffer is not defined"
58+
- **Fix**: Ensure `web/_headers` exists and is deployed. Note that some local dev servers (like `python -m http.server`) do NOT send these headers. Use `npm run dev` (Node.js) or `npm run dev:worker` (Wrangler) for local testing.

0 commit comments

Comments
 (0)