Files
cmc_frontend/DockerFile
2025-10-09 20:05:39 +05:30

38 lines
856 B
Plaintext

# Use Node.js LTS Alpine for smaller image
FROM node:20-alpine AS base
# Set working directory
WORKDIR /app
# Install dependencies only when needed
FROM base AS deps
COPY package.json package-lock.json* ./
RUN npm install --frozen-lockfile || npm install
# Build the app
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Production image, copy only necessary files
FROM base AS runner
ENV NODE_ENV=production
# Create non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
WORKDIR /app
# Copy build output and node_modules
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
USER nextjs
EXPOSE 3000
CMD ["npm", "start"]