43 lines
1.0 KiB
Docker
43 lines
1.0 KiB
Docker
# syntax=docker/dockerfile:1
|
|
FROM oven/bun:1.3.5-alpine AS base
|
|
WORKDIR /app
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# --------------------------
|
|
# Stage 1: Dependencies
|
|
# --------------------------
|
|
FROM base AS dependencies
|
|
COPY package.json bun.lock ./
|
|
RUN --mount=type=cache,target=/root/.bun/install/cache \
|
|
bun install --frozen-lockfile
|
|
|
|
# --------------------------
|
|
# Stage 2: Build
|
|
# --------------------------
|
|
FROM base AS builder
|
|
ENV NODE_ENV=production
|
|
|
|
COPY --from=dependencies /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN bun run build
|
|
|
|
# --------------------------
|
|
# Stage 3: Start
|
|
# --------------------------
|
|
FROM oven/bun:1.3.5-alpine AS runner
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs \
|
|
&& apk add --no-cache dumb-init
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
|
|
CMD ["dumb-init", "bun", "server.js"]
|