+31
-31
@@ -1,33 +1,33 @@
|
|||||||
# -------- Build Stage --------
|
# -------- Build Stage --------
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy only dependency files first (better cache)
|
# Copy only dependency files first (better cache)
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Use clean install for reproducible builds
|
# Install devDependencies too (vite, etc.) even when NODE_ENV=production
|
||||||
RUN npm ci
|
RUN npm ci --include=dev
|
||||||
|
|
||||||
# Copy source after deps (maximizes cache usage)
|
# Copy source after deps (maximizes cache usage)
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build with production mode
|
# Build with production mode
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
# -------- Production Stage --------
|
# -------- Production Stage --------
|
||||||
FROM nginx:stable-alpine AS production
|
FROM nginx:stable-alpine AS production
|
||||||
|
|
||||||
# Copy built assets
|
# Copy built assets
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
# Copy nginx config (optional, safer naming)
|
# Copy nginx config (optional, safer naming)
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# Remove default nginx config if needed (optional safety)
|
# Remove default nginx config if needed (optional safety)
|
||||||
RUN rm -f /etc/nginx/conf.d/default.conf.default || true
|
RUN rm -f /etc/nginx/conf.d/default.conf.default || true
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
Reference in New Issue
Block a user