Buckets:
| # ============================================ | |
| # Stage 1: Dependencies Installation Stage | |
| # ============================================ | |
| # This Dockerfile.bun is specifically configured for projects using Bun | |
| # For npm/pnpm or yarn, refer to the Dockerfile instead | |
| FROM oven/bun:1 AS dependencies | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy package-related files first to leverage Docker's caching mechanism | |
| COPY package.json bun.lock* ./ | |
| # Install project dependencies with frozen lockfile for reproducible builds | |
| RUN --mount=type=cache,target=/root/.bun/install/cache \ | |
| bun install --no-save --frozen-lockfile | |
| # ============================================ | |
| # Stage 2: Build Next.js application in standalone mode | |
| # ============================================ | |
| FROM oven/bun:1 AS builder | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy project dependencies from dependencies stage | |
| COPY --from=dependencies /app/node_modules ./node_modules | |
| # Copy application source code | |
| COPY . . | |
| ENV NODE_ENV=production | |
| # 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 | |
| # Build Next.js application | |
| RUN bun run build | |
| # ============================================ | |
| # Stage 3: Run Next.js application | |
| # ============================================ | |
| FROM oven/bun:1 AS runner | |
| # Set working directory | |
| WORKDIR /app | |
| # Set production environment variables | |
| ENV NODE_ENV=production | |
| ENV PORT=3000 | |
| ENV HOSTNAME="0.0.0.0" | |
| # 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 run time. | |
| # ENV NEXT_TELEMETRY_DISABLED=1 | |
| # Copy production assets | |
| COPY --from=builder --chown=bun:bun /app/public ./public | |
| # Set the correct permission for prerender cache | |
| RUN mkdir .next | |
| RUN chown bun:bun .next | |
| # Automatically leverage output traces to reduce image size | |
| # https://nextjs.org/docs/advanced-features/output-file-tracing | |
| COPY --from=builder --chown=bun:bun /app/.next/standalone ./ | |
| COPY --from=builder --chown=bun:bun /app/.next/static ./.next/static | |
| # If you want to persist the fetch cache generated during the build so that | |
| # cached responses are available immediately on startup, uncomment this line: | |
| # COPY --from=builder --chown=bun:bun /app/.next/cache ./.next/cache | |
| # Switch to non-root user for security best practices | |
| USER bun | |
| # Expose port 3000 to allow HTTP traffic | |
| EXPOSE 3000 | |
| # Start Next.js standalone server with Bun | |
| CMD ["bun", "server.js"] | |
Xet Storage Details
- Size:
- 2.69 kB
- Xet hash:
- b2cf8da7d13421f333df3c9484c5c8c0e50893f34d02b1b819852b752808a275
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.