44 lines
990 B
Docker
44 lines
990 B
Docker
# ========================================
|
|
# Stage 1: Dependencies
|
|
# ========================================
|
|
FROM node:20-alpine AS deps
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies with Chinese mirror
|
|
RUN npm config set registry https://registry.npmmirror.com && \
|
|
npm ci
|
|
|
|
# ========================================
|
|
# Stage 2: Builder
|
|
# ========================================
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Build the application (skip type check for production)
|
|
RUN npx vite build
|
|
|
|
# ========================================
|
|
# Stage 3: Runner with Nginx
|
|
# ========================================
|
|
FROM nginx:alpine AS runner
|
|
|
|
# Copy built assets from builder
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Copy custom nginx config
|
|
COPY nginx.docker.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Expose port
|
|
EXPOSE 80
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|