|
|
@@ -1,11 +1,20 @@
|
|
|
+# ============ 构建阶段 ============
|
|
|
+FROM node:18-alpine AS builder
|
|
|
+
|
|
|
+WORKDIR /app
|
|
|
+
|
|
|
+COPY package.json package-lock.json ./
|
|
|
+RUN npm config set registry https://registry.npmmirror.com && npm install
|
|
|
+
|
|
|
+COPY . .
|
|
|
+RUN npx vite build
|
|
|
+
|
|
|
+# ============ 运行阶段 ============
|
|
|
FROM nginx:alpine
|
|
|
|
|
|
-# 复制 nginx 配置
|
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
+COPY --from=builder /app/dist /usr/share/nginx/html/
|
|
|
|
|
|
-# 复制前端构建产物
|
|
|
-COPY dist/ /usr/share/nginx/html/
|
|
|
-
|
|
|
-EXPOSE 80
|
|
|
+EXPOSE 9007
|
|
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|