pnpm payload migrate exits 1 in the migrator container likely due to TLA issues with Lexical packages (same issue seen with migrate:create). Replace with a small src/scripts/migrate.ts that calls payload.db.migrate() programmatically, using the same NODE_OPTIONS approach that works for seed.ts: NODE_OPTIONS="--experimental-strip-types --no-require-module" Also add migrator log output to the CD workflow for easier debugging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54 lines
1.4 KiB
Docker
54 lines
1.4 KiB
Docker
FROM node:22-slim AS base
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
WORKDIR /app
|
|
|
|
# --- Dependencies ---
|
|
FROM base AS deps
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# --- Development ---
|
|
FROM base AS dev
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NODE_ENV=development
|
|
ENV WATCHPACK_POLLING=true
|
|
EXPOSE 3000
|
|
CMD ["pnpm", "dev"]
|
|
|
|
# --- Migrator (deps + src only — runs migrations before app starts) ---
|
|
FROM base AS migrator
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
# Same Node.js native TS-stripping approach used by seed.ts (avoids TLA issues with lexical)
|
|
ENV NODE_OPTIONS="--experimental-strip-types --no-require-module"
|
|
CMD ["node", "src/scripts/migrate.ts"]
|
|
|
|
# --- Build ---
|
|
FROM base AS build
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN pnpm build
|
|
|
|
# --- Production ---
|
|
FROM node:22-slim AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=build /app/public ./public
|
|
COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=build --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"]
|