231250141 8 mesiacov pred
rodič
commit
32e339ae90
2 zmenil súbory, kde vykonal 49 pridanie a 0 odobranie
  1. 25 0
      Dockerfile
  2. 24 0
      nginx.conf

+ 25 - 0
Dockerfile

@@ -0,0 +1,25 @@
+# ===== 构建阶段 =====
+FROM node:22-alpine AS builder
+
+WORKDIR /app
+
+# 复制依赖文件并安装
+COPY package*.json ./
+RUN npm install
+
+# 复制源码并构建
+COPY . .
+RUN npm run build-only
+
+# ===== 运行阶段 =====
+FROM nginx:stable-alpine
+
+# 复制构建产物到 nginx 目录
+COPY --from=builder /app/dist /usr/share/nginx/html
+
+# 复制 nginx 配置
+COPY nginx.conf /etc/nginx/conf.d/default.conf
+
+EXPOSE 80
+
+CMD ["nginx", "-g", "daemon off;"]

+ 24 - 0
nginx.conf

@@ -0,0 +1,24 @@
+server {
+    listen 80;
+    server_name review.seec.seecoder.cn;
+
+    root /usr/share/nginx/html;
+    index index.html;
+
+    # 解决 Vue Router history 模式刷新 404
+    location / {
+        try_files $uri $uri/ /index.html;
+    }
+
+    # 静态资源缓存
+    location ~* \.(js|css|png|svg|ico|woff2?)$ {
+        expires 7d;
+        add_header Cache-Control "public, immutable";
+    }
+
+    # 健康检查
+    location /health {
+        return 200 "ok";
+        add_header Content-Type text/plain;
+    }
+}