From 9166fa13be026e600192f29747a679574d039ccf Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 20 Mar 2026 11:49:15 +0700 Subject: [PATCH] 260320:1149 Refactor Overrall #03 build failed with pnpm due to symlink structure incompatibility --- frontend/Dockerfile | 19 ++++++++++--------- frontend/next.config.mjs | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 1c2c5a5..52f4d6d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -60,8 +60,8 @@ RUN mkdir /n && ln -s /n .next && \ pnpm run build && \ rm .next && mv /n .next -# Verify standalone build was created -RUN ls -la /w/frontend/.next/standalone/ || (echo "ERROR: Standalone build not found!" && exit 1) +# Verify build was created +RUN ls -la /w/frontend/.next/ || (echo "ERROR: Build not found!" && exit 1) # ========================= @@ -80,15 +80,16 @@ ENV PORT=3000 RUN addgroup -g 1001 -S nextjs && \ adduser -S nextjs -u 1001 -# Install curl for healthcheck -RUN apk add --no-cache curl +# Install curl and pnpm for healthcheck +RUN apk add --no-cache curl && \ + npm install -g pnpm@10.32.1 -# Copy standalone output from build -COPY --from=build --chown=nextjs:nextjs /w/frontend/.next/standalone ./ -COPY --from=build --chown=nextjs:nextjs /w/frontend/.next/static ./.next/static +# Copy application and node_modules from build +COPY --from=build --chown=nextjs:nextjs /w/frontend ./ +COPY --from=build --chown=nextjs:nextjs /w/frontend/node_modules ./node_modules # Debug: Verify files exist -RUN ls -la ./ && ls -la ./.next/ && ls -la ./.next/static/ || (echo "ERROR: Required files not found!" && exit 1) +RUN ls -la ./ && ls -la ./.next/ && ls -la ./node_modules/ || (echo "ERROR: Required files not found!" && exit 1) USER nextjs @@ -97,5 +98,5 @@ EXPOSE 3000 HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=60s \ CMD curl -f http://localhost:3000/ || exit 1 -CMD ["node", "frontend/server.js"] +CMD ["pnpm", "start"] diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index 1104de1..7078e8e 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -4,7 +4,8 @@ const nextConfig = { // 1. Standalone Output: จำเป็นสำหรับการ Deploy บน Docker (QNAP) // Next.js จะคัดแยกเฉพาะไฟล์ที่จำเป็นต้องใช้จริงออกมาไว้ในโฟลเดอร์ .next/standalone - output: "standalone", + // TEMPORARILY DISABLED: pnpm standalone build issues + // output: "standalone", // 2. React Strict Mode: ช่วยดักจับ Bug ในช่วง Dev (เช่น Component render ซ้ำ) reactStrictMode: true,