Spaces:
No application file
No application file
| # Install dependencies only when needed | |
| FROM registry.access.redhat.com/ubi8/nodejs-18-minimal:1-86 AS deps | |
| USER 0 | |
| WORKDIR /app | |
| # Install dependencies based on the preferred package manager | |
| COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | |
| RUN \ | |
| if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | |
| elif [ -f package-lock.json ]; then npm ci; \ | |
| elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \ | |
| else echo "Lockfile not found." && exit 1; \ | |
| fi | |
| # Rebuild the source code only when needed | |
| FROM registry.access.redhat.com/ubi8/nodejs-18-minimal:1-86 AS builder | |
| USER 0 | |
| WORKDIR /app | |
| COPY --from=deps /app/node_modules ./node_modules | |
| COPY . . | |
| # Next.js collects completely anonymous telemetry data about general usage. | |
| # Learn more here: https://nextjs.org/telemetry | |
| # Uncomment the following line in case you want to disable telemetry during the build. | |
| ENV NEXT_TELEMETRY_DISABLED 1 | |
| # If using npm comment out above and use below instead | |
| RUN npm run build | |
| # Production image, copy all the files and run next | |
| FROM registry.access.redhat.com/ubi8/nodejs-18-minimal:1-86 AS runner | |
| USER 0 | |
| WORKDIR /app | |
| ENV NODE_ENV production | |
| # Uncomment the following line in case you want to enable telemetry during runtime. | |
| ENV NEXT_TELEMETRY_DISABLED 1 | |
| #COPY --from=builder /app/public ./public | |
| # Set the correct permission for prerender cache | |
| RUN mkdir .next | |
| RUN chown 1001:1001 .next | |
| # Automatically leverage output traces to reduce image size | |
| # https://nextjs.org/docs/advanced-features/output-file-tracing | |
| COPY --from=builder --chown=1001:1001 /app/.next/standalone ./ | |
| COPY --from=builder --chown=1001:1001 /app/.next/static ./.next/static | |
| USER 1001 | |
| EXPOSE 8501 | |
| ENV PORT 8501 | |
| CMD ["sh", "-c", "HOSTNAME=0.0.0.0 node server"] | |