perf: use oven/bun:1-alpine as production image

This commit is contained in:
hamster1963 2024-10-06 01:01:19 +08:00
parent bd16fcc140
commit f4150f0473
3 changed files with 12 additions and 30 deletions

View File

@ -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"]

BIN
bun.lockb

Binary file not shown.

View File

@ -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",
@ -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",