|
6 | 6 |
|
7 | 7 | ## Useful commands:
|
8 | 8 |
|
| 9 | +### Prerequisites |
| 10 | +- Optional: [install wrangler globally](https://developers.cloudflare.com/workers/wrangler/install-and-update/#install-wrangler-globally) by running `npm install --global wrangler` |
| 11 | + |
9 | 12 | ### For backend
|
10 |
| -- Run backend locally: `npx wrangler dev` |
11 |
| -- Deploy backend application: `npx wrangler publish` |
12 |
| - - Read logs in realtime: `npx wrangler tail` |
| 13 | +- Install dependencies: `pnpm i` |
| 14 | +- Run backend locally: `wrangler dev` |
| 15 | +- Deploy backend application: `wrangler publish` |
| 16 | + - Read logs in realtime: `wrangler tail` |
| 17 | + - Warning: if you use the wrong imports (unoptimised), the worker can be quite large. |
| 18 | + - The maximum it can be is 5MB. Currently, it is `Total Upload: 1722.06 KiB / gzip: 570.04 KiB`. |
13 | 19 | - Reset database to `schema.sql`:
|
14 |
| - - Reset preview database: `npx wrangler d1 execute banananator_preview --file schemas/schema.sql` |
15 |
| - - Reset production database: `npx wrangler d1 execute banananator --file schemas/schema.sql` |
| 20 | + - Reset preview database: `wrangler d1 execute banananator_preview --file schemas/schema.sql` |
| 21 | + - Reset production database: `wrangler d1 execute banananator --file schemas/schema.sql` |
| 22 | + |
| 23 | +## Rust worker compilation |
| 24 | + - Set up `.env` file containing token for accessing worker. Create one in https://dash.cloudflare.com/profile/api-tokens |
| 25 | + - Build image and start container: `docker-compose up -d --build` |
| 26 | + - Enter container: `docker exec -it backend-development-1 bash` |
| 27 | + - Install wasm-pack: run `curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh` |
| 28 | + - Ensure it is the latest version from . Check your current version by running `wasm-pack -V`. Install using another method if necessary. I found reinstalling it with the same command fixed it. |
| 29 | + - Install worker-build, run `cargo install -q worker-build` |
| 30 | + - Install wasm-bindegen: `cargo install wasm-bindgen-cli` |
| 31 | + - Install rust using [rust-up](https://rustup.rs/): run `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` |
| 32 | + - Launch the backend dev server: run `wrangler dev` |
16 | 33 |
|
17 | 34 | ### For client
|
18 | 35 | - Deploy web application:
|
19 | 36 | - `cd ../client/`
|
20 | 37 | - `flutter build web`
|
21 | 38 | - `cd -`
|
22 |
| - - `npx wrangler pages publish ../client/build/web --project-name=banananator` |
23 |
| - - To deploy fragile version, run: `npx wrangler pages publish ../client/build/web --project-name=banananator-fragile` |
| 39 | + - `wrangler pages publish ../client/build/web --project-name=banananator` |
| 40 | + - To deploy fragile version, run: `wrangler pages publish ../client/build/web --project-name=banananator-fragile` |
24 | 41 | - See https://developers.cloudflare.com/pages/platform/direct-upload/#wrangler-cli
|
25 | 42 |
|
26 | 43 |
|
|
0 commit comments