mohsin-devs commited on
Commit
26e2a42
Β·
1 Parent(s): 7a52698

Fix: Install Node.js via official precompiled tarball in Stage 3 to resolve setup_20.x script error

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -3
Dockerfile CHANGED
@@ -18,7 +18,23 @@ WORKDIR /frontend
18
  COPY frontend/package.json frontend/package-lock.json* ./
19
  RUN npm install --legacy-peer-deps --quiet
20
 
21
- COPY frontend/ .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  # In HF, frontend calls go through the same origin via Nginx proxy
24
  # So NEXT_PUBLIC_API_URL is empty β€” rewrites handle /api/* internally
@@ -26,6 +42,9 @@ ARG NEXT_PUBLIC_API_URL=""
26
  ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
27
  ENV NEXT_TELEMETRY_DISABLED=1
28
 
 
 
 
29
  RUN npm run build
30
 
31
  # ─── Stage 2: Python dependencies ────────────────────────────────────────────
@@ -51,8 +70,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
51
  curl \
52
  libpq5 \
53
  ca-certificates \
54
- && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
55
- && apt-get install -y --no-install-recommends nodejs \
56
  && rm -rf /var/lib/apt/lists/*
57
 
58
  # ── Python packages ───────────────────────────────────────────────────────────
 
18
  COPY frontend/package.json frontend/package-lock.json* ./
19
  RUN npm install --legacy-peer-deps --quiet
20
 
21
+ # Copy only the necessary frontend files (deterministic for HF build context)
22
+ COPY frontend/package.json frontend/package-lock.json* ./
23
+ COPY frontend/next.config.mjs ./
24
+ COPY frontend/tsconfig.json ./
25
+ COPY frontend/next-env.d.ts ./
26
+ COPY frontend/public ./public
27
+ COPY frontend/src ./src
28
+ COPY frontend/app ./app
29
+ COPY frontend/pages ./pages
30
+
31
+ # Verify app layout exists (better failure message in CI/HF logs)
32
+ RUN if [ ! -d "app" ] && [ ! -d "src/app" ] && [ ! -d "pages" ]; then \
33
+ echo "ERROR: no 'app', 'src/app' or 'pages' directory found in frontend - Next.js requires an 'app' or 'pages' directory"; \
34
+ ls -la /frontend || true; \
35
+ ls -la /frontend/src || true; \
36
+ exit 1; \
37
+ fi
38
 
39
  # In HF, frontend calls go through the same origin via Nginx proxy
40
  # So NEXT_PUBLIC_API_URL is empty β€” rewrites handle /api/* internally
 
42
  ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
43
  ENV NEXT_TELEMETRY_DISABLED=1
44
 
45
+ # Increase Node heap for Next.js builds to avoid OOM in constrained builders
46
+ ENV NODE_OPTIONS="--max-old-space-size=4096"
47
+
48
  RUN npm run build
49
 
50
  # ─── Stage 2: Python dependencies ────────────────────────────────────────────
 
70
  curl \
71
  libpq5 \
72
  ca-certificates \
73
+ xz-utils \
74
+ && curl -fsSL https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz | tar -xJ --strip-components=1 -C /usr/local \
75
  && rm -rf /var/lib/apt/lists/*
76
 
77
  # ── Python packages ───────────────────────────────────────────────────────────