136 lines
2.9 KiB
Markdown
136 lines
2.9 KiB
Markdown
# Build & Deployment Instructions
|
|
|
|
## Prerequisites
|
|
|
|
- Node.js (v18 or higher)
|
|
- pnpm package manager
|
|
- Cloudflare account with Wrangler CLI configured
|
|
|
|
## Development
|
|
|
|
Start the development server:
|
|
|
|
```bash
|
|
pnpm dev
|
|
```
|
|
|
|
The app will be available at `http://localhost:3000`
|
|
|
|
## Building for Production
|
|
|
|
### 1. Build Next.js Application
|
|
|
|
```bash
|
|
pnpm build
|
|
```
|
|
|
|
This runs `next build` and creates an optimized production build in `.next/`
|
|
|
|
### 2. Build for Cloudflare with OpenNext
|
|
|
|
```bash
|
|
npx @opennextjs/cloudflare build
|
|
```
|
|
|
|
This command:
|
|
- Runs the Next.js build (if not already built)
|
|
- Converts the Next.js output to Cloudflare Workers format
|
|
- Creates the deployment-ready bundle in `.open-next/`
|
|
- Generates the worker script and static assets
|
|
|
|
**Note:** You must run this step before deploying to Cloudflare. The standard `next build` alone is not sufficient.
|
|
|
|
## Deployment
|
|
|
|
### Deploy to Cloudflare Workers
|
|
|
|
```bash
|
|
npx wrangler deploy
|
|
```
|
|
|
|
Or specify an environment explicitly:
|
|
|
|
```bash
|
|
npx wrangler deploy --env="" # Deploy to default environment
|
|
```
|
|
|
|
The deployment will:
|
|
- Upload new/modified static assets
|
|
- Deploy the worker script
|
|
- Provide a live URL (e.g., `https://inspiration-repo-agent.nicholaivogelfilms.workers.dev`)
|
|
|
|
## Complete Build & Deploy Workflow
|
|
|
|
```bash
|
|
# 1. Build Next.js app and prepare for Cloudflare
|
|
npx @opennextjs/cloudflare build
|
|
|
|
# 2. Deploy to Cloudflare
|
|
npx wrangler deploy
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
### Local Development
|
|
|
|
Create a `.env.local` file in the project root:
|
|
|
|
```env
|
|
AGENT_1_URL=https://n8n.example.com/webhook/agent-1-uuid
|
|
AGENT_1_NAME=Agent Name
|
|
AGENT_1_DESCRIPTION=Description of the agent
|
|
|
|
AGENT_2_URL=https://n8n.example.com/webhook/agent-2-uuid
|
|
AGENT_2_NAME=Another Agent
|
|
AGENT_2_DESCRIPTION=Description of another agent
|
|
```
|
|
|
|
### Production (Cloudflare)
|
|
|
|
Set environment variables in the Cloudflare dashboard:
|
|
1. Go to Workers & Pages → `inspiration-repo-agent` → Settings → Environment Variables
|
|
2. Add the same `AGENT_*` variables as above
|
|
3. Redeploy for changes to take effect
|
|
|
|
## Troubleshooting
|
|
|
|
### "No updated asset files to upload"
|
|
|
|
This means the OpenNext build hasn't been run or hasn't picked up your changes. Run:
|
|
|
|
```bash
|
|
npx @opennextjs/cloudflare build
|
|
```
|
|
|
|
Then deploy again.
|
|
|
|
### ESLint Configuration Error
|
|
|
|
If you see ESLint errors during build, the build will still complete successfully. The linting step can be skipped if needed.
|
|
|
|
### Multiple Environments Warning
|
|
|
|
If you see a warning about multiple environments, explicitly specify the environment:
|
|
|
|
```bash
|
|
npx wrangler deploy --env=""
|
|
```
|
|
|
|
## Package Manager
|
|
|
|
This project uses **pnpm** (not npm). Always use `pnpm` commands:
|
|
|
|
- `pnpm install` - Install dependencies
|
|
- `pnpm dev` - Start dev server
|
|
- `pnpm build` - Build Next.js app
|
|
|
|
## Tech Stack
|
|
|
|
- **Framework:** Next.js 15.5.4 (App Router)
|
|
- **Runtime:** Cloudflare Workers
|
|
- **Adapter:** @opennextjs/cloudflare
|
|
- **Styling:** Tailwind CSS 4.1.9
|
|
- **Package Manager:** pnpm
|
|
|
|
|