Skip to content
Open
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
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Claw3D — 3D agent visualization for OpenClaw
# Multi-stage build: install deps → build Next.js → run with custom server

FROM node:20-slim AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --ignore-scripts

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production image includes all devDependencies unnecessarily

Medium Severity

The deps stage runs npm ci --ignore-scripts without --omit=dev, so devDependencies (Playwright, jsdom, Vitest, ESLint, etc.) are installed. These flow through the builder stage into the runner stage via the node_modules copy. This contradicts the stated goal of "minimal image size" from the three-stage build and adds significant bloat plus unnecessary attack surface to the production image.

Additional Locations (1)
Fix in Cursor Fix in Web


FROM node:20-slim AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing .dockerignore lets COPY . . overwrite clean deps

High Severity

There is no .dockerignore file in the repository. The COPY . . in the builder stage runs after COPY --from=deps /app/node_modules ./node_modules, so if a node_modules/ directory exists on the build host, it overwrites the clean, reproducible install from the deps stage. This defeats the purpose of the multi-stage build and npm ci. It also sends the entire repository (including .git/, test files, .env files with potential secrets) into the build context and image layers.

Fix in Cursor Fix in Web

ENV NEXT_TELEMETRY_DISABLED=1
# Build-time gateway URL (overridden at runtime by CLAW3D_GATEWAY_URL)
ENV NEXT_PUBLIC_GATEWAY_URL=ws://localhost:18789
RUN npm run build

FROM node:20-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

# Copy built app + custom server + node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/server ./server
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/next.config.ts ./next.config.ts

EXPOSE 3000

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