Files
eCommerce-website/Dockerfile
2026-02-19 18:34:10 +05:30

29 lines
959 B
Docker

# ─── Stage 1: Build ──────────────────────────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies first (layer-cache friendly)
COPY package.json package-lock.json ./
RUN npm ci --frozen-lockfile
# Copy source and build
COPY . .
RUN npm run build
# ─── Stage 2: Serve ──────────────────────────────────────────────────────────
FROM nginx:1.27-alpine AS runner
# Remove default nginx content
RUN rm -rf /usr/share/nginx/html/*
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy custom nginx config (handles SPA routing)
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]