42 lines
1.2 KiB
Docker
42 lines
1.2 KiB
Docker
# 1. Install dependencies only when needed
|
|
FROM oven/bun:1 AS deps
|
|
WORKDIR /app
|
|
|
|
# Install dependencies based on the preferred package manager
|
|
COPY package.json bun.lockb* ./
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# 2. Rebuild the source code only when needed
|
|
FROM oven/bun:1 AS builder
|
|
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
|
|
|
|
RUN bun run build
|
|
|
|
# 3. Production image, copy all the files and run next
|
|
FROM oven/bun:1 AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV production
|
|
# Uncomment the following line in case you want to disable telemetry during runtime.
|
|
# ENV NEXT_TELEMETRY_DISABLED 1
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=bun:bun /app/.next/standalone ./
|
|
COPY --from=builder --chown=bun:bun /app/.next/static ./.next/static
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT 3000
|
|
ENV HOSTNAME "0.0.0.0"
|
|
|
|
# server.js is created by next build from the standalone output
|
|
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
|
|
CMD ["node", "server.js"]
|