bf9e827f85
Deploy backend, frontend, PostgreSQL, and Redis on Kubernetes with optional Ingress/TLS, SQL migration hooks, and public registry exposure at repo.3fase.ir. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
942 B
Docker
43 lines
942 B
Docker
# ---- Stage 1: Dependencies ----
|
|
FROM node:20-alpine AS deps
|
|
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
|
|
# ---- Stage 2: Build ----
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
ARG NEXT_PUBLIC_API_URL=http://localhost:4000
|
|
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN npm run build
|
|
|
|
# ---- Stage 3: Production ----
|
|
FROM node:20-alpine AS production
|
|
|
|
RUN apk add --no-cache dumb-init
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
WORKDIR /app
|
|
|
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=appuser:appgroup /app/.next/standalone ./
|
|
COPY --from=builder --chown=appuser:appgroup /app/.next/static ./.next/static
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
ENTRYPOINT ["dumb-init", "--"]
|
|
CMD ["node", "server.js"]
|