Spaces:
Running
Running
| FROM node:20-bookworm-slim AS base | |
| # Install dependencies only when needed | |
| FROM base AS deps | |
| WORKDIR /app | |
| COPY package.json package-lock.json ./ | |
| RUN npm ci --maxsockets 5 --network-timeout 120000 | |
| # The lockfile is generated on Windows, so install the Linux GNU native bindings | |
| # Tailwind and Lightning CSS need inside the Debian-based HF build image. | |
| RUN npm install --no-save @tailwindcss/oxide-linux-x64-gnu@4.1.13 lightningcss-linux-x64-gnu@1.30.1 | |
| # Build the application | |
| FROM base AS builder | |
| WORKDIR /app | |
| COPY --from=deps /app/node_modules ./node_modules | |
| COPY . . | |
| ENV NEXT_TELEMETRY_DISABLED=1 | |
| ENV NODE_OPTIONS="--max-old-space-size=4096" | |
| RUN npm run build | |
| # Production image | |
| FROM base AS runner | |
| WORKDIR /app | |
| ENV NODE_ENV=production | |
| ENV NEXT_TELEMETRY_DISABLED=1 | |
| ENV PORT=7860 | |
| ENV HOSTNAME="0.0.0.0" | |
| RUN addgroup --system --gid 1001 nodejs | |
| RUN adduser --system --uid 1001 nextjs | |
| COPY --from=builder /app/public ./public | |
| COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | |
| COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | |
| USER nextjs | |
| EXPOSE 7860 | |
| CMD ["node", "server.js"] | |