Spaces:
Sleeping
Sleeping
Fix hung Next build: SSG timeout + fast-fail backend URL
Browse files- Dockerfile +6 -2
- next.config.js +6 -3
Dockerfile
CHANGED
|
@@ -20,8 +20,12 @@ COPY --from=deps /app/node_modules ./node_modules
|
|
| 20 |
COPY . .
|
| 21 |
# Optional reactflow repair after full tree is present
|
| 22 |
RUN node scripts/verify-reactflow.js || true
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
RUN npm run build
|
| 26 |
|
| 27 |
FROM node:20-bookworm-slim AS runner
|
|
|
|
| 20 |
COPY . .
|
| 21 |
# Optional reactflow repair after full tree is present
|
| 22 |
RUN node scripts/verify-reactflow.js || true
|
| 23 |
+
# During image build there is no backend — use a fast-fail URL so SSG cannot hang
|
| 24 |
+
ARG NEXT_PUBLIC_API_URL=http://127.0.0.1:9
|
| 25 |
+
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} \
|
| 26 |
+
API_BASE_URL=${NEXT_PUBLIC_API_URL} \
|
| 27 |
+
BACKEND_URL=${NEXT_PUBLIC_API_URL} \
|
| 28 |
+
PYTHON_BACKEND_URL=${NEXT_PUBLIC_API_URL}
|
| 29 |
RUN npm run build
|
| 30 |
|
| 31 |
FROM node:20-bookworm-slim AS runner
|
next.config.js
CHANGED
|
@@ -14,6 +14,8 @@ const nextConfig = {
|
|
| 14 |
typescript: {
|
| 15 |
ignoreBuildErrors: true,
|
| 16 |
},
|
|
|
|
|
|
|
| 17 |
output: 'standalone',
|
| 18 |
images: {
|
| 19 |
unoptimized: true,
|
|
@@ -21,12 +23,13 @@ const nextConfig = {
|
|
| 21 |
transpilePackages: ["@chakra-ui/react", "@chakra-ui/icons", "@ark-ui/react"],
|
| 22 |
outputFileTracingRoot: process.cwd(),
|
| 23 |
|
| 24 |
-
//
|
| 25 |
-
|
| 26 |
-
productionBrowserSourceMaps: true,
|
| 27 |
|
| 28 |
experimental: {
|
| 29 |
externalDir: true,
|
|
|
|
|
|
|
| 30 |
},
|
| 31 |
|
| 32 |
// Disable minification via webpack configuration
|
|
|
|
| 14 |
typescript: {
|
| 15 |
ignoreBuildErrors: true,
|
| 16 |
},
|
| 17 |
+
// Fail hung getStaticProps/API calls during build instead of waiting forever
|
| 18 |
+
staticPageGenerationTimeout: 45,
|
| 19 |
output: 'standalone',
|
| 20 |
images: {
|
| 21 |
unoptimized: true,
|
|
|
|
| 23 |
transpilePackages: ["@chakra-ui/react", "@chakra-ui/icons", "@ark-ui/react"],
|
| 24 |
outputFileTracingRoot: process.cwd(),
|
| 25 |
|
| 26 |
+
// Source maps bloat HF image build; disable in Space package
|
| 27 |
+
productionBrowserSourceMaps: false,
|
|
|
|
| 28 |
|
| 29 |
experimental: {
|
| 30 |
externalDir: true,
|
| 31 |
+
// Fewer page-data workers on small HF builders (avoids thrash/hangs)
|
| 32 |
+
cpus: 2,
|
| 33 |
},
|
| 34 |
|
| 35 |
// Disable minification via webpack configuration
|