Skip to content

Commit

Permalink
Updated README with wrangler commands
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminEHowe committed Jul 2, 2024
1 parent da20082 commit 4cc4350
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ _site
.jekyll-metadata
vendor
node_modules
.wrangler
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@ Benjamin Howe's personal website, deployed to Cloudflare Pages. Originally gener

Clone this repository in a convenient location.

To run locally without Docker [install Ruby and Jekyll](https://jekyllrb.com/docs/step-by-step/01-setup/).
To run Jekyll locally without Docker [install Ruby and Jekyll](https://jekyllrb.com/docs/step-by-step/01-setup/). Wrangler requires [Node.js](https://nodejs.org/) as unfortunately [the maintainers of Wrangler have decided against having an official container image for Wrangler](https://github.com/cloudflare/workers-sdk/issues/1316#issuecomment-1658608450).

## Usage

Install gems using `bundle install` and then run `bundle exec jekyll serve` and navigate to http://127.0.0.1:4000.

### Using Docker
The easiest way to run Jekyll is using Docker:

- Windows (cmd): `docker run -it --rm -v %cd%:/app -w /app -p 127.0.0.1:4000:4000 ruby:3.3.1 sh -c "bundle install && bundle exec jekyll serve --force_polling -H 0.0.0.0"`
- macOS & Linux (bash): `docker run -it --rm -v "$PWD":/app -w /app -p 127.0.0.1:4000:4000 ruby:3.3.1 sh -c "bundle install && bundle exec jekyll serve -H 0.0.0.0"`

### Using Wrangler

To test some of the dynamic aspects of the website (e.g. [Cloudflare Pages Functions](https://developers.cloudflare.com/pages/functions/)), it is necessary to use [Wrangler](https://developers.cloudflare.com/workers/wrangler/).

To set up a local database:

`npx wrangler@latest d1 execute beh-uk-forms --local --file=./sql/beh-uk-forms-schema.sql`

(note that Windows users will need to convert the line endings in the SQL file to `LF` to work around [a bug in `workerd`](https://github.com/cloudflare/workerd/issues/1300))

Run the appropriate commend for Jekyll (see above) _without_ the port forward and listen hostname, then also run:

`npx wrangler@latest pages dev --port 4000 _site`

## Tests

Sadly there aren't any, yet, at least. I plan to fix this!
Expand Down
1 change: 1 addition & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ name = "beh-uk"

[[d1_databases]]
binding = "DB_FORMS"
preview_database_id = "DB_FORMS"
database_name = "beh-uk-forms"
database_id = "acb261ce-be3c-46d4-a89b-a6587eca3440"

0 comments on commit 4cc4350

Please sign in to comment.