perf(docker): prune runtime before copy
This commit is contained in:
+8
-10
@@ -10,18 +10,22 @@ RUN --mount=type=cache,target=/root/.bun/install/cache \
|
|||||||
bun install --frozen-lockfile
|
bun install --frozen-lockfile
|
||||||
|
|
||||||
# Stage 2: Build the application
|
# Stage 2: Build the application
|
||||||
FROM oven/bun:1.3.14-alpine AS builder
|
FROM deps AS builder
|
||||||
WORKDIR /app
|
ARG TARGETARCH
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
COPY . .
|
COPY . .
|
||||||
# Build Next.js
|
# Build Next.js
|
||||||
RUN --mount=type=cache,target=/app/.next/cache \
|
RUN --mount=type=cache,target=/app/.next/cache \
|
||||||
bun run build
|
bun run build
|
||||||
|
|
||||||
|
# The standalone tracer includes both glibc and musl Sharp packages. Alpine only
|
||||||
|
# needs musl, so prune the incompatible copy before it enters a runtime layer.
|
||||||
|
RUN rm -rf \
|
||||||
|
".next/standalone/node_modules/@img/sharp-linux-${TARGETARCH}" \
|
||||||
|
".next/standalone/node_modules/@img/sharp-libvips-linux-${TARGETARCH}"
|
||||||
|
|
||||||
# Stage 3: Production runner
|
# Stage 3: Production runner
|
||||||
FROM oven/bun:1.3.14-alpine AS runner
|
FROM oven/bun:1.3.14-alpine AS runner
|
||||||
ARG TARGETARCH
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
@@ -33,12 +37,6 @@ COPY --from=builder /app/.next/standalone ./
|
|||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
|
|
||||||
# The standalone tracer includes both glibc and musl Sharp packages. Alpine only
|
|
||||||
# needs musl, so discard the incompatible duplicate without touching runtime deps.
|
|
||||||
RUN rm -rf \
|
|
||||||
"./node_modules/@img/sharp-linux-${TARGETARCH}" \
|
|
||||||
"./node_modules/@img/sharp-libvips-linux-${TARGETARCH}"
|
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["bun", "server.js"]
|
CMD ["bun", "server.js"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user