perf(build): make standalone image deterministic
This commit is contained in:
+14
-5
@@ -12,6 +12,7 @@ RUN --mount=type=cache,target=/root/.bun/install/cache \
|
||||
# Stage 2: Build the application
|
||||
FROM oven/bun:1.3.14-alpine AS builder
|
||||
WORKDIR /app
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
# Build Next.js
|
||||
@@ -20,18 +21,26 @@ RUN --mount=type=cache,target=/app/.next/cache \
|
||||
|
||||
# Stage 3: Production runner
|
||||
FROM oven/bun:1.3.14-alpine AS runner
|
||||
ARG TARGETARCH
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV PORT=3000
|
||||
|
||||
# Copy built assets and dependencies from builder stage
|
||||
# Copy the standalone server and static assets without the full dependency tree
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
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
|
||||
CMD ["bun", "start"]
|
||||
CMD ["bun", "server.js"]
|
||||
|
||||
# Stage 4: Scheduled video upload worker
|
||||
FROM deps AS video-upload-worker
|
||||
|
||||
Reference in New Issue
Block a user