fix: payload building issues

This commit is contained in:
2026-06-17 23:58:51 +05:30
parent d3ab5028af
commit e974313f6d
15 changed files with 264 additions and 271 deletions
+11
View File
@@ -0,0 +1,11 @@
node_modules
.next
dist
build
.cache
media
uploads
.env
.env.*
!.env.example
*.log
+1 -5
View File
@@ -1,4 +1,4 @@
# Payload
# Payload (used for local dev via `pnpm dev:cms`)
PAYLOAD_SECRET=change-me-to-a-long-random-string
DATABASE_URI=postgres://payload:payload@localhost:5432/softvowels
@@ -9,8 +9,4 @@ SERVER_URL=https://cms.softvowels.example
# Origins allowed to call the API (Astro public site)
CORS_ORIGINS=https://softvowels.example,http://localhost:4321
# Internal rebuild webhook
ASTRO_REVALIDATE_URL=http://host.docker.internal:4321/__revalidate
ASTRO_REVALIDATE_TOKEN=change-me
PORT=3000
+28 -8
View File
@@ -1,17 +1,23 @@
# syntax=docker/dockerfile:1.7
#
# PayloadCMS production image. Built and run by docker-compose.
# We install pnpm globally via npm so we don't depend on corepack's
# (sometimes strict) version negotiation.
#
# We use Next.js `output: 'standalone'` so the runtime stage doesn't have
# to ship the entire node_modules tree — Next analyses the code, picks
# only the files that are actually required at runtime, and bundles them
# under .next/standalone/. This sidesteps the pnpm content-addressable
# store / bin-link issues we hit with the workspace install.
#
# We install pnpm via `npm install -g pnpm@9` instead of corepack so
# the version negotiation is unambiguous across Node 20 minor releases.
FROM node:20-alpine AS base
RUN npm install -g pnpm@9
WORKDIR /repo
# ---- deps -----------------------------------------------------------------
# Install ALL workspace deps at the root so the `apps/cms` package can
# resolve its siblings (@payloadcms/*, next, react, etc.) and the root
# tooling (prettier) is also available.
# Install ALL workspace deps at the root so apps/cms can resolve its
# siblings (@payloadcms/*, next, react, etc.).
FROM base AS deps
COPY pnpm-workspace.yaml package.json ./
COPY apps/cms/package.json ./apps/cms/package.json
@@ -29,11 +35,25 @@ FROM deps AS build
COPY apps/cms ./apps/cms
WORKDIR /repo/apps/cms
RUN pnpm run build
# Some apps don't ship a `public/` dir; ensure one exists so the
# runtime COPY below doesn't fail.
RUN mkdir -p /repo/apps/cms/public
# ---- runtime --------------------------------------------------------------
FROM base AS runtime
# Compose the self-contained runtime image from the standalone output.
# - .next/standalone/ contains the server.js entrypoint and a trimmed
# node_modules tree with only the files Next determined are needed.
# - .next/static/ is the hashed client-side bundles; standalone
# does NOT include it, so we copy it over manually.
# - public/ static assets served from the web root (may be
# absent; the COPY is guarded).
FROM node:20-alpine AS runtime
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
WORKDIR /repo/apps/cms
COPY --from=build /repo ./
COPY --from=build /repo/apps/cms/.next/standalone ./
COPY --from=build /repo/apps/cms/.next/static ./.next/static
COPY --from=build /repo/apps/cms/public ./public
EXPOSE 3000
CMD ["pnpm", "start"]
CMD ["node", "server.js"]
+1
View File
@@ -2,6 +2,7 @@ import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
reactStrictMode: true,
output: 'standalone',
experimental: {
reactCompiler: false,
},