Refactor: Switch Docker base image to Bun

This commit is contained in:
2026-03-14 18:00:30 -07:00
parent bc02328acd
commit 74d49935be

View File

@@ -1,18 +1,18 @@
FROM node:18-alpine AS base FROM oven/bun:alpine AS base
# Install dependencies only when needed # Install dependencies only when needed
FROM base AS deps FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
# Copy package files (Bun can install from package.json just fine)
COPY package.json package-lock.json* ./ COPY package.json package-lock.json* ./
RUN npm install RUN bun install
# Rebuild the source code only when needed # Rebuild the source code only when needed
FROM base AS builder FROM base AS builder
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
RUN npm run build RUN bun run build
# Production image, copy all the files and run next # Production image, copy all the files and run next
FROM base AS runner FROM base AS runner
@@ -25,6 +25,7 @@ RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
# Next.js standalone output works perfectly via Bun
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
@@ -32,4 +33,5 @@ USER nextjs
EXPOSE 3004 EXPOSE 3004
CMD ["node", "server.js"] # Run the Next.js standalone server using Bun instead of Node
CMD ["bun", "server.js"]