-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: use oven/bun:1-alpine as production image
- Loading branch information
1 parent
bd16fcc
commit f4150f0
Showing
3 changed files
with
12 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,25 @@ | ||
FROM oven/bun:1 AS base | ||
|
||
# Stage 1: Install dependencies | ||
FROM base AS deps | ||
WORKDIR /app | ||
COPY package.json bun.lockb ./ | ||
RUN bun install --frozen-lockfile | ||
|
||
|
||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* bun.lockb* ./ | ||
RUN bun install | ||
|
||
|
||
# Stage 2: Build the application | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
|
||
RUN bun run build | ||
|
||
|
||
FROM node:21-alpine AS runner | ||
|
||
# Stage 3: Production image | ||
FROM oven/bun:1-alpine AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
ENV NODE_ENV=production | ||
COPY --from=builder /app/public ./public | ||
|
||
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/.env.example ./.env | ||
|
||
USER nextjs | ||
COPY --from=builder /app/.next/standalone ./ | ||
COPY --from=builder /app/.next/static ./.next/static | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
ENV HOSTNAME "0.0.0.0" | ||
|
||
CMD ["node", "server.js"] | ||
CMD ["bun", "run", "server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters