The previous multi-stage `deps` → `builder` split copied only the root /app/node_modules from the deps stage, but pnpm workspaces also create per-package node_modules directories (e.g. apps/web/node_modules) that contain the .bin symlinks for `next`, `tsup`, etc. Without those, the builder stage failed with `sh: tsup: not found` and `sh: next: not found`. Collapse `deps` and `builder` into a single stage so the per-package node_modules survive intact. pnpm's content-addressable store keeps re-installs nearly free on cache hits, and Docker layer caching still short-circuits the install step when only source files change. For collab and mcp runner stages, also copy the per-app node_modules so runtime dependency resolution works. Made-with: Cursor
55 lines
1.8 KiB
Text
55 lines
1.8 KiB
Text
# syntax=docker/dockerfile:1
|
|
|
|
ARG NODE_VERSION=20.18.1
|
|
FROM node:${NODE_VERSION}-alpine AS base
|
|
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
|
WORKDIR /app
|
|
|
|
# --- Builder ---
|
|
# Install deps + build in one stage so pnpm's per-package node_modules
|
|
# (containing .bin symlinks like `next`, `tsup`) are intact.
|
|
# pnpm's content-addressable store keeps re-installs fast on cache hits.
|
|
FROM base AS builder
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json tsconfig.json ./
|
|
COPY apps/web/package.json ./apps/web/
|
|
COPY apps/collab-server/package.json ./apps/collab-server/
|
|
COPY apps/mcp-server/package.json ./apps/mcp-server/
|
|
COPY packages/database/package.json ./packages/database/
|
|
COPY packages/shared/package.json ./packages/shared/
|
|
COPY packages/ai/package.json ./packages/ai/
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
COPY apps/web ./apps/web
|
|
COPY packages/database ./packages/database
|
|
COPY packages/shared ./packages/shared
|
|
COPY docker/next.config.docker.ts ./apps/web/next.config.ts
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV NODE_ENV=production
|
|
|
|
RUN pnpm exec turbo build --filter=@tasks/web
|
|
|
|
# --- Production runner ---
|
|
FROM node:${NODE_VERSION}-alpine AS runner
|
|
RUN apk add --no-cache wget \
|
|
&& addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
|
CMD wget -qO- --timeout=3 http://127.0.0.1:3000/ >/dev/null || exit 1
|
|
|
|
CMD ["node", "apps/web/server.js"]
|