d65f8cdf48
- Introduced a multi-stage build process to optimize the Docker image size and build time. - Added a dedicated stage for dependencies installation using pnpm, enhancing package management. - Separated the build stage to compile the application, ensuring a cleaner final image. - Updated the runner stage to copy only necessary files from the build stage, improving runtime performance.
30 lines
638 B
Docker
30 lines
638 B
Docker
FROM docker-mirror.ravanertebat.ir/hub/node:22.14 AS base
|
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="${PNPM_HOME}:${PATH}"
|
|
|
|
WORKDIR /app
|
|
RUN corepack enable
|
|
|
|
FROM base AS deps
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
FROM base AS builder
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN pnpm run build
|
|
|
|
FROM docker-mirror.ravanertebat.ir/hub/node:22.14 AS runner
|
|
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/public ./public
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "server.js"] |