Skip to content

Commit 42b7eac

Browse files
committed
fix: resolve cv-process API 404 error in production
- Update Dockerfile to use pnpm instead of npm for consistency - Install pnpm globally in both deps and builder stages - Copy pnpm-lock.yaml for deterministic builds - Use pnpm commands for install and build - Fix cv-process route temp file path from /tmp/ to /app/temp_images/ - Use Docker container's properly configured temp directory - Ensures correct permissions for file operations - These changes resolve the 404 error on /api/cv-process endpoint - Package manager mismatch was causing build inconsistencies - File permission issues were causing runtime failures Fixes: CV upload processing in production deployment
1 parent 35e6fad commit 42b7eac

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ FROM base AS deps
77
RUN apk add --no-cache libc6-compat
88
WORKDIR /app
99

10-
# Copy package files from frontend directory
11-
COPY frontend/package*.json ./
12-
# Install dependencies
13-
RUN npm ci
10+
# Install pnpm
11+
RUN npm install -g pnpm
12+
13+
# Copy package files from frontend directory (including pnpm-lock.yaml)
14+
COPY frontend/package.json frontend/pnpm-lock.yaml ./
15+
# Install dependencies using pnpm with frozen lockfile
16+
RUN pnpm install --frozen-lockfile
1417

1518
# Rebuild the source code only when needed
1619
FROM base AS builder
1720
WORKDIR /app
21+
22+
# Install pnpm in builder stage
23+
RUN npm install -g pnpm
24+
1825
COPY --from=deps /app/node_modules ./node_modules
1926
COPY frontend/ .
2027

@@ -46,8 +53,8 @@ ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
4653
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
4754
ENV SUPABASE_SERVICE_ROLE_KEY=$SUPABASE_SERVICE_ROLE_KEY
4855

49-
# Build the Next.js app
50-
RUN npm run build
56+
# Build the Next.js app using pnpm
57+
RUN pnpm run build
5158

5259
# Production image, copy all the files and run next
5360
FROM base AS runner

frontend/src/app/api/cv-process/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function POST(request: Request) {
5050

5151
// Convert blob to buffer and save as temporary file
5252
const buffer = Buffer.from(await fileData.arrayBuffer());
53-
const tempFilePath = `/tmp/cv_${applicant_id}_${Date.now()}.pdf`;
53+
const tempFilePath = `/app/temp_images/cv_${applicant_id}_${Date.now()}.pdf`;
5454

5555
// Write to temp file (processCvPdf expects file path)
5656
const fs = await import('fs');

0 commit comments

Comments
 (0)