From 8777c45a443173e69c689643c735b4c513e25d72 Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 1 Apr 2026 17:44:48 +0800 Subject: [PATCH 1/2] fix(build): resolve ESLint and type errors causing build failure --- src/app/api/auth/login/route.ts | 6 +++--- src/app/api/auth/register/route.ts | 5 +++-- src/app/api/auth/resend/route.ts | 5 +++-- src/app/api/auth/send-otp-register/route.ts | 5 +++-- .../darmasaba/_com/main-page/apbdes/lib/grafikRealisasi.tsx | 4 ++-- src/app/darmasaba/_com/main-page/apbdes/lib/paguTable.tsx | 1 - .../darmasaba/_com/main-page/apbdes/lib/realisasiTable.tsx | 1 - 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/app/api/auth/login/route.ts b/src/app/api/auth/login/route.ts index 1b9baccf..87d7deb4 100644 --- a/src/app/api/auth/login/route.ts +++ b/src/app/api/auth/login/route.ts @@ -43,7 +43,6 @@ export async function POST(req: Request) { try { const res = await fetch(waUrl); if (!res.ok) { - const errorText = await res.text(); console.error(`⚠️ WA Service HTTP Error: ${res.status} ${res.statusText}. Continuing since OTP is logged.`); console.log(`💡 Use this OTP to login: ${codeOtp}`); } else { @@ -53,8 +52,9 @@ export async function POST(req: Request) { console.error("⚠️ WA Service Logic Error:", sendWa); } } - } catch (waError: any) { - console.error("⚠️ WA Connection Exception. Continuing since OTP is logged.", waError.message); + } catch (waError: unknown) { + const errorMessage = waError instanceof Error ? waError.message : String(waError); + console.error("⚠️ WA Connection Exception. Continuing since OTP is logged.", errorMessage); } const createOtpId = await prisma.kodeOtp.create({ diff --git a/src/app/api/auth/register/route.ts b/src/app/api/auth/register/route.ts index 83ec5bb6..122e3f1a 100644 --- a/src/app/api/auth/register/route.ts +++ b/src/app/api/auth/register/route.ts @@ -35,8 +35,9 @@ export async function POST(req: Request) { const waData = await waRes.json(); console.log("📱 WA Response (Register):", waData); } - } catch (waError: any) { - console.warn("⚠️ WA Connection Exception (Register). Continuing since OTP is logged.", waError.message); + } catch (waError: unknown) { + const errorMessage = waError instanceof Error ? waError.message : String(waError); + console.warn("⚠️ WA Connection Exception (Register). Continuing since OTP is logged.", errorMessage); } // ✅ Simpan OTP ke database diff --git a/src/app/api/auth/resend/route.ts b/src/app/api/auth/resend/route.ts index 5d06728c..b19ee66f 100644 --- a/src/app/api/auth/resend/route.ts +++ b/src/app/api/auth/resend/route.ts @@ -31,8 +31,9 @@ export async function POST(req: Request) { const waData = await waRes.json(); console.log("📱 WA Response (Resend):", waData); } - } catch (waError: any) { - console.warn("⚠️ WA Connection Exception (Resend). Continuing since OTP is logged.", waError.message); + } catch (waError: unknown) { + const errorMessage = waError instanceof Error ? waError.message : String(waError); + console.warn("⚠️ WA Connection Exception (Resend). Continuing since OTP is logged.", errorMessage); } // Simpan OTP ke database diff --git a/src/app/api/auth/send-otp-register/route.ts b/src/app/api/auth/send-otp-register/route.ts index d944b15e..e578349f 100644 --- a/src/app/api/auth/send-otp-register/route.ts +++ b/src/app/api/auth/send-otp-register/route.ts @@ -34,8 +34,9 @@ export async function POST(req: Request) { const sendWa = await res.json(); console.log("📱 WA Response (SendOTPRegister):", sendWa); } - } catch (waError: any) { - console.warn("⚠️ WA Connection Exception (SendOTPRegister). Continuing since OTP is logged.", waError.message); + } catch (waError: unknown) { + const errorMessage = waError instanceof Error ? waError.message : String(waError); + console.warn("⚠️ WA Connection Exception (SendOTPRegister). Continuing since OTP is logged.", errorMessage); } // Simpan OTP diff --git a/src/app/darmasaba/_com/main-page/apbdes/lib/grafikRealisasi.tsx b/src/app/darmasaba/_com/main-page/apbdes/lib/grafikRealisasi.tsx index 07bdb183..f1c97dde 100644 --- a/src/app/darmasaba/_com/main-page/apbdes/lib/grafikRealisasi.tsx +++ b/src/app/darmasaba/_com/main-page/apbdes/lib/grafikRealisasi.tsx @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Paper, Title, Progress, Stack, Text, Group, Box, rem } from '@mantine/core' +import { Paper, Title, Progress, Stack, Text, Group, Box } from '@mantine/core' import { IconArrowUpRight, IconArrowDownRight } from '@tabler/icons-react' -import { APBDes, APBDesItem, SummaryData } from '../types/apbdes' +import { APBDes, APBDesItem } from '../types/apbdes' interface SummaryProps { title: string diff --git a/src/app/darmasaba/_com/main-page/apbdes/lib/paguTable.tsx b/src/app/darmasaba/_com/main-page/apbdes/lib/paguTable.tsx index 04794c4c..2bb8343d 100644 --- a/src/app/darmasaba/_com/main-page/apbdes/lib/paguTable.tsx +++ b/src/app/darmasaba/_com/main-page/apbdes/lib/paguTable.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { Paper, Table, Title, Box, ScrollArea, Badge } from '@mantine/core' import { APBDes, APBDesItem } from '../types/apbdes' diff --git a/src/app/darmasaba/_com/main-page/apbdes/lib/realisasiTable.tsx b/src/app/darmasaba/_com/main-page/apbdes/lib/realisasiTable.tsx index 7aea80f5..334db64f 100644 --- a/src/app/darmasaba/_com/main-page/apbdes/lib/realisasiTable.tsx +++ b/src/app/darmasaba/_com/main-page/apbdes/lib/realisasiTable.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { Paper, Table, Title, Badge, Text, Box, ScrollArea } from '@mantine/core' import { APBDes, APBDesItem, RealisasiItem } from '../types/apbdes' From 970949a68b983eb582a9b3757917353cdd7b63b7 Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 2 Apr 2026 11:24:49 +0800 Subject: [PATCH 2/2] fix: resolve Docker build failure by optimizing configuration and prisma signal handling - Added .dockerignore to prevent build poisoning from local artifacts. - Updated Dockerfile with stable Bun version, memory limits, and missing config files. - Refined prisma.ts signal handlers to avoid process termination during Next.js build phases. - Synchronized eslint-config-next with Next.js version. --- .dockerignore | 47 +++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 22 +++++++++++++++++----- package.json | 2 +- src/lib/prisma.ts | 22 ++++++++++++---------- 4 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4329df51 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,47 @@ +node_modules +.next +.git +.env +.env.local +.env.development.local +.env.test.local +.env.production.local +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +bun-debug.log* + +# Docker files +Dockerfile +.dockerignore + +# OS files +.DS_Store +Thumbs.db + +# Markdown/Documentation +README.md +GEMINI.md +AGENTS.md +AUDIT_REPORT.md +QWEN.md +NOTE.md +task-project-apbdes.md +MUSIK_CREATE_ANALYSIS.md +darkMode.md +/test-results +/playwright-report +/tmp_assets +/foldergambar +/googleapi +/xx +/xx.ts +/xx.txt +/test.txt +/x.json +/x.sh +/xcoba.ts +/xcoba2.ts +/gambar.ttx +/test-berita-state.ts diff --git a/Dockerfile b/Dockerfile index 914bf441..52c3a542 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build -FROM oven/bun:1.3 AS build +FROM oven/bun:1.1 AS build # Install build dependencies for native modules RUN apt-get update && apt-get install -y \ @@ -11,10 +11,18 @@ RUN apt-get update && apt-get install -y \ # Set the working directory WORKDIR /app +# Disable telemetry and set build-time environment +ENV NEXT_TELEMETRY_DISABLED=1 +ENV NODE_ENV=production +ENV NODE_OPTIONS="--max-old-space-size=4096" +# Critical ENV for API route evaluation during build +ENV WIBU_UPLOAD_DIR=uploads +ENV DATABASE_URL="postgresql://bip:Production_123@pgbouncer:5432/desa-darmasaba-staging?pgbouncer=true" + # Copy package files COPY package.json bun.lock* ./ -# Install dependencies +# Install dependencies with frozen lockfile RUN bun install --frozen-lockfile # Copy the rest of the application code @@ -27,14 +35,16 @@ RUN cp .env.example .env RUN bun x prisma generate # Build the application frontend -ENV NODE_ENV=production RUN bun run build # Stage 2: Runtime -FROM oven/bun:1.3-slim AS runtime +FROM oven/bun:1.1-slim AS runtime # Set environment variables ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +# Ensure runtime also has critical envs if they are checked at startup +ENV WIBU_UPLOAD_DIR=uploads # Install runtime dependencies RUN apt-get update && apt-get install -y \ @@ -46,10 +56,12 @@ WORKDIR /app # Copy necessary files from build stage COPY --from=build /app/package.json ./ +COPY --from=build /app/bun.lock* ./ +COPY --from=build /app/next.config.ts ./ +COPY --from=build /app/postcss.config.cjs ./ COPY --from=build /app/tsconfig.json ./ COPY --from=build /app/.next ./.next COPY --from=build /app/public ./public -COPY --from=build /app/src ./src COPY --from=build /app/node_modules ./node_modules COPY --from=build /app/prisma ./prisma diff --git a/package.json b/package.json index a6d06d6d..7893de0b 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "@types/react-dom": "^19", "@vitest/ui": "^4.0.18", "eslint": "^9", - "eslint-config-next": "15.1.6", + "eslint-config-next": "15.5.12", "jsdom": "^28.0.0", "msw": "^2.12.9", "parcel": "^2.6.2", diff --git a/src/lib/prisma.ts b/src/lib/prisma.ts index ccd8945e..778a7e6b 100644 --- a/src/lib/prisma.ts +++ b/src/lib/prisma.ts @@ -29,16 +29,18 @@ process.on('unhandledRejection', async (error) => { }); // Handle graceful shutdown -process.on('SIGINT', async () => { - console.log('Received SIGINT signal. Closing database connections...'); - await prisma.$disconnect(); - process.exit(0); -}); +if (process.env.NODE_ENV === 'production' && !process.env.NEXT_PHASE) { + process.on('SIGINT', async () => { + console.log('Received SIGINT signal. Closing database connections...'); + await prisma.$disconnect(); + // Allow natural exit + }); -process.on('SIGTERM', async () => { - console.log('Received SIGTERM signal. Closing database connections...'); - await prisma.$disconnect(); - process.exit(0); -}); + process.on('SIGTERM', async () => { + console.log('Received SIGTERM signal. Closing database connections...'); + await prisma.$disconnect(); + // Allow natural exit + }); +} export default prisma; \ No newline at end of file