Files
KalBot/Dockerfile

38 lines
934 B
Docker

FROM oven/bun:alpine AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
# Copy package files (Bun can install from package.json just fine)
COPY package.json package-lock.json* ./
RUN bun install
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN bun run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3004
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
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/static ./.next/static
USER nextjs
EXPOSE 3004
# Run the Next.js standalone server using Bun instead of Node
CMD ["bun", "server.js"]