Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
build
dist
.DS_Store

64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM node:20-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json package-lock.json* ./
RUN \
if [ -f package-lock.json ]; then npm ci; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Accept build argument for public variable
ARG NEXT_PUBLIC_CHATKIT_WORKFLOW_ID
ENV NEXT_PUBLIC_CHATKIT_WORKFLOW_ID=$NEXT_PUBLIC_CHATKIT_WORKFLOW_ID

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED=1

RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT=3000
ENV HOSTNAME="0.0.0.0"

CMD ["node", "server.js"]

22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,31 @@ Visit `http://localhost:3000` and start chatting. Use the prompts on the start s

### 5. Deploy your app

**⚠️ IMPORTANT: Domain Verification Required for Production**

Before deploying your app to production, you **must** register your production domain with OpenAI ChatKit. This is required to prevent the `DomainVerificationRequestError: Domain verification request failed with 401` error.

1. **Add your domain to the allowlist:**

- Go to [Domain Allowlist Settings](https://platform.openai.com/settings/organization/security/domain-allowlist)
- Add your production domain (e.g., `yourdomain.com` or `app.yourdomain.com`)
- Wait a few minutes for the change to propagate

2. **Set production environment variables:**

- Ensure `OPENAI_API_KEY` is set in your production environment
- Ensure `NEXT_PUBLIC_CHATKIT_WORKFLOW_ID` is set in your production environment
- Both must be from the same OpenAI organization/project as your Agent Builder workflow

> **Note:** When using `HostedApiConfig` (with `getClientSecret`), domain verification is handled automatically by OpenAI's servers when your domain is registered in the allowlist. The domain key (`domain_pk_...`) is only needed if you're using `CustomApiConfig` with a custom backend URL.

3. **Build and deploy:**

```bash
npm run build
```

Before deploying your app, you need to verify the domain by adding it to the [Domain allowlist](https://platform.openai.com/settings/organization/security/domain-allowlist) on your dashboard.
> **Note:** Domain verification is only required for production deployments. Local development (localhost) does not require domain verification.

## Customization Tips

Expand Down
Loading