# Stage 1: Build the application FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/node:20-alpine AS builder WORKDIR /app # Enable pnpm RUN corepack enable && corepack prepare pnpm@latest --activate # Copy package management files COPY package.json pnpm-lock.yaml ./ # Install dependencies (ignoring scripts to speed up and safer) # Removing frozen-lockfile restriction in case of version mismatch, ensuring install works RUN pnpm install --no-frozen-lockfile # Copy source code COPY . . # Build the project RUN pnpm build # Stage 2: Serve with Nginx FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nginx:alpine # Copy built assets from builder stage COPY --from=builder /app/dist /usr/share/nginx/html # Expose port 80 (internal container port) EXPOSE 80 # Start Nginx CMD ["nginx", "-g", "daemon off;"]