Skip to content

Commit

Permalink
perf: use oven/bun:1-alpine as production image
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Oct 5, 2024
1 parent bd16fcc commit f4150f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
38 changes: 10 additions & 28 deletions Dockerfile
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"]
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.3",
"@types/luxon": "^3.4.2",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"caniuse-lite": "^1.0.30001667",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down Expand Up @@ -53,7 +53,7 @@
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.11.1",
"eslint": "^9.12.0",
"eslint-config-next": "^14.2.14",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
Expand Down

0 comments on commit f4150f0

Please sign in to comment.