G# PenX
Deploy a dynamic blog using Cloudflare Pages, D1, R2, and AI.
To deploy PenX to cloudflare, follow these steps:
First, clone the PenX project to your local machine by executing the following command:
git clone https://github.com/penx-labs/penx
Next, rename wrangler.toml.example
to wrangler.toml
.
Run the following command to create a Cloudflare D1 database:
npx wrangler d1 create penx-blog
If successful, you will see a confirmation message similar to this:
✅ Successfully created DB 'penx-blog' in region WNAM
Created your new D1 database.
[[d1_databases]]
binding = "DB"
database_name = "penx-blog"
database_id = "00e31c14-e6ae-4612-9bc3-d25c6a1f8023d"
Copy the database_id
and update it in your wrangler.toml
file.
Before create R2 Bucket, you need to bind a credit card to Cloudflare.
Create a Cloudflare R2 bucket by running:
npx wrangler r2 bucket create penx-bucket
You should receive a message confirming the creation of the bucket:
✅ Created bucket 'penx-bucket' with default storage class of Standard.
Configure your Worker to write objects to this bucket:
[[r2_buckets]]
bucket_name = "penx-bucket"
binding = "penx_bucket"
To set up a session password, visit this link to generate a secure password. Replace SESSION_PASSWORD
in your wrangler.toml
with this value.
Finally, deploy your blog by running these commands:
pnpm install
pnpm run db:generate # Required for initial release
pnpm run db:migrate:prod # Required for initial release
pnpm run deploy
Upon successful deployment, you will receive a URL like: https://penx-cloudflare.pages.dev.