Rewrite Dockerfile
This commit is contained in:
+7
-25
@@ -1,38 +1,20 @@
|
|||||||
## syntax=docker/dockerfile:1.7
|
FROM node:22-bookworm-slim
|
||||||
|
|
||||||
# ---- deps ----
|
|
||||||
FROM node:latest AS deps
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends libc6 openssl ca-certificates \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
RUN npm ci --no-audit --no-fund
|
RUN npm ci --no-audit --no-fund
|
||||||
|
|
||||||
# ---- build ----
|
|
||||||
FROM node:latest AS builder
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# ---- runner ----
|
|
||||||
FROM node:latest AS runner
|
|
||||||
WORKDIR /app
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
ENV HOSTNAME=0.0.0.0
|
ENV HOSTNAME=0.0.0.0
|
||||||
|
|
||||||
RUN groupadd --system --gid 1001 nodejs \
|
RUN npm run build
|
||||||
&& useradd --system --uid 1001 --gid nodejs nextjs
|
|
||||||
|
|
||||||
# Standalone output copies only what's needed at runtime.
|
|
||||||
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
|
|
||||||
|
|
||||||
USER nextjs
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
CMD ["node", "server.js"]
|
CMD ["npm", "start"]
|
||||||
Reference in New Issue
Block a user