Skip to content

Commit c9d91f3

Browse files
committed
chore: add docker configuration
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1 parent 3b22338 commit c9d91f3

File tree

7 files changed

+12957
-2
lines changed

7 files changed

+12957
-2
lines changed

.dockerignore

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Dependencies
2+
node_modules
3+
.pnp
4+
.pnp.js
5+
6+
# Python
7+
__pycache__
8+
*.py[cod]
9+
*$py.class
10+
.Python
11+
env/
12+
venv/
13+
.venv
14+
pip-log.txt
15+
pip-delete-this-directory.txt
16+
.pytest_cache
17+
18+
# Testing
19+
coverage
20+
*.lcov
21+
.nyc_output
22+
23+
# Build outputs
24+
.next/
25+
out/
26+
dist/
27+
build/
28+
*.tsbuildinfo
29+
30+
# Environment
31+
.env
32+
.env*.local
33+
.env.production
34+
35+
# Logs
36+
logs
37+
*.log
38+
npm-debug.log*
39+
yarn-debug.log*
40+
yarn-error.log*
41+
lerna-debug.log*
42+
.pnpm-debug.log*
43+
44+
# OS
45+
.DS_Store
46+
*.pem
47+
Thumbs.db
48+
49+
# IDE
50+
.vscode
51+
.idea
52+
*.swp
53+
*.swo
54+
*~
55+
56+
# Git
57+
.git
58+
.gitignore
59+
.gitattributes
60+
61+
# Documentation
62+
*.md
63+
!README.md
64+
65+
# Turbo
66+
.turbo
67+
68+
# Misc
69+
.cache
70+
tmp
71+
temp

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ next-env.d.ts
4444
# lock files
4545
package-lock.json
4646
yarn.lock
47-
pnpm-lock.yaml
4847
bun.lockb
4948

5049
# LangGraph API

apps/app/next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
4+
output: "standalone",
45
serverExternalPackages: ["@copilotkit/runtime"],
56
};
67

apps/app/src/app/api/copilotkit/ag-ui-middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const aguiMiddleware = [
55
mcpServers: [
66
{
77
type: "http",
8-
url: "http://localhost:3108/mcp",
8+
url: process.env.MCP_SERVER_URL || "http://localhost:3108/mcp",
99
serverId: "example_mcp_app",
1010
},
1111
],

docker/Dockerfile.app

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Dockerfile for Next.js App
2+
FROM node:22-alpine AS base
3+
4+
# Install dependencies only when needed
5+
FROM base AS deps
6+
RUN apk add --no-cache libc6-compat
7+
8+
WORKDIR /app
9+
10+
# Install pnpm
11+
RUN corepack enable && corepack prepare pnpm@latest --activate
12+
13+
# Copy package files
14+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
15+
COPY apps/app/package.json ./apps/app/
16+
COPY turbo.json ./
17+
18+
# Install dependencies
19+
RUN pnpm install --frozen-lockfile
20+
21+
# Build the application
22+
FROM base AS builder
23+
WORKDIR /app
24+
25+
# Copy dependencies from deps stage
26+
COPY --from=deps /app/node_modules ./node_modules
27+
COPY --from=deps /app/apps/app/node_modules ./apps/app/node_modules
28+
29+
# Copy source code
30+
COPY . .
31+
32+
# Enable pnpm
33+
RUN corepack enable && corepack prepare pnpm@latest --activate
34+
35+
# Build the Next.js app
36+
RUN pnpm --filter @repo/app build
37+
38+
# Production image
39+
FROM base AS runner
40+
WORKDIR /app
41+
42+
ENV NODE_ENV=production
43+
44+
RUN addgroup --system --gid 1001 nodejs
45+
RUN adduser --system --uid 1001 nextjs
46+
47+
# Copy built application
48+
COPY --from=builder /app/apps/app/public ./apps/app/public
49+
COPY --from=builder --chown=nextjs:nodejs /app/apps/app/.next/standalone ./
50+
COPY --from=builder --chown=nextjs:nodejs /app/apps/app/.next/static ./apps/app/.next/static
51+
52+
USER nextjs
53+
54+
EXPOSE 3000
55+
56+
ENV PORT=3000
57+
ENV HOSTNAME="0.0.0.0"
58+
59+
CMD ["node", "apps/app/server.js"]

docker/Dockerfile.mcp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Dockerfile for MCP Server
2+
FROM node:22-alpine AS base
3+
4+
# Install dependencies
5+
FROM base AS deps
6+
RUN apk add --no-cache libc6-compat
7+
8+
WORKDIR /app
9+
10+
# Install pnpm
11+
RUN corepack enable && corepack prepare pnpm@latest --activate
12+
13+
# Copy package files
14+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
15+
COPY apps/mcp/package.json ./apps/mcp/
16+
COPY turbo.json ./
17+
18+
# Install dependencies
19+
RUN pnpm install --frozen-lockfile
20+
21+
# Build the MCP app
22+
FROM base AS builder
23+
WORKDIR /app
24+
25+
# Copy dependencies
26+
COPY --from=deps /app/node_modules ./node_modules
27+
COPY --from=deps /app/apps/mcp/node_modules ./apps/mcp/node_modules
28+
29+
# Copy source code
30+
COPY apps/mcp ./apps/mcp
31+
COPY package.json pnpm-workspace.yaml turbo.json ./
32+
33+
# Enable pnpm
34+
RUN corepack enable && corepack prepare pnpm@latest --activate
35+
36+
# Build the MCP app
37+
RUN pnpm --filter @repo/mcp build
38+
39+
# Production image
40+
FROM base AS runner
41+
WORKDIR /app
42+
43+
ENV NODE_ENV=production
44+
45+
RUN addgroup --system --gid 1001 nodejs
46+
RUN adduser --system --uid 1001 mcpuser
47+
48+
# Install tsx globally using npm
49+
RUN npm install -g tsx
50+
51+
# Copy built application and dependencies
52+
COPY --from=builder /app/apps/mcp/dist ./apps/mcp/dist
53+
COPY --from=builder /app/apps/mcp/server.ts ./apps/mcp/
54+
COPY --from=builder /app/apps/mcp/server-utils.ts ./apps/mcp/
55+
COPY --from=builder /app/apps/mcp/package.json ./apps/mcp/
56+
COPY --from=builder /app/node_modules ./node_modules
57+
COPY --from=builder /app/apps/mcp/node_modules ./apps/mcp/node_modules
58+
59+
RUN chown -R mcpuser:nodejs /app
60+
61+
USER mcpuser
62+
63+
WORKDIR /app/apps/mcp
64+
65+
EXPOSE 3108
66+
67+
ENV PORT=3108
68+
69+
CMD ["tsx", "server.ts"]

0 commit comments

Comments
 (0)