Files
Aut.ManagementFaculty/Dockerfile
T

50 lines
1.5 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# syntax=docker/dockerfile:1
# ---- Dependencies ----
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
# Skip audit/fund in image builds (saves ~30–60s); keep npm cache across deploys.
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit --no-fund
# ---- Builder ----
FROM node:22-alpine AS builder
WORKDIR /app
ARG NEXT_PUBLIC_SITE_URL=https://edu.mstaut.ir
ENV NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL
ENV NEXT_TELEMETRY_DISABLED=1
# Skip React Compiler in image builds (big CPU/RAM cost on self-hosted runners)
ENV DISABLE_REACT_COMPILER=1
ENV NODE_OPTIONS=--max-old-space-size=3072
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Explicit webpack: Next 16 default Turbopack often stalls/OOMs in constrained CI
RUN npm run build
# ---- Runner ----
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
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
# Writable dir for admin image uploads (mount a volume in compose for persistence).
# Keep this outside public/: Next standalone does not serve runtime public files.
RUN rm -rf ./public/uploads \
&& mkdir -p ./uploads \
&& chown -R nextjs:nodejs ./uploads
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]