ソースを参照

build:为项目添加 Docker支持并配置 Nginx- 新增 Dockerfile 和 default_prod.conf 文件,用于构建和配置 Nginx 服务器
- 修改 .env 文件,添加 BASE_URL 配置
- 更新 vue.config.js,设置 publicPath 为 '/sddnWeihe'

王杰 3 ヶ月 前
コミット
2a9af58802
4 ファイル変更41 行追加2 行削除
  1. 1 1
      .env
  2. 11 0
      Dockerfile
  3. 28 0
      default_prod.conf
  4. 1 1
      vue.config.js

+ 1 - 1
.env

@@ -1,3 +1,3 @@
 VUE_APP_MARS3D_SOURCE=module
 
-# VUE_APP_MARS3D_SOURCE=local
+BASE_URL= /sddnWeihe

+ 11 - 0
Dockerfile

@@ -0,0 +1,11 @@
+FROM nginx:1.22.1
+LABEL maintainer="lideshou <lides@newland.com.cn>"
+
+# 定义构建参数
+ARG env
+
+RUN rm /etc/nginx/conf.d/default.conf
+ADD default_prod.conf /etc/nginx/conf.d/default.conf
+COPY dist/ /usr/share/nginx/html/
+COPY dist/ /usr/share/nginx/html/sddnWeihe/
+

+ 28 - 0
default_prod.conf

@@ -0,0 +1,28 @@
+server {
+    listen               28133 default_server;
+    client_max_body_size 500M;
+    location / {
+        gzip              on;
+        gzip_min_length   1k;
+        gzip_buffers      4                      16k;
+        gzip_http_version 1.0;
+        gzip_comp_level   2;
+        gzip_types        text/plain             application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
+        gzip_vary         on;
+        root              /usr/share/nginx/html/;
+        # 用于配合 browserHistory 使用
+        try_files         $uri                   $uri/                  /index.html;
+        index             index.html             index.htm;
+    }
+    location /api {
+        proxy_set_header Host                        $http_host;
+        proxy_set_header X-Real-IP                   $remote_addr;
+        proxy_set_header REMOTE-HOST                 $remote_addr;
+        proxy_set_header X-Forwarded-For             $proxy_add_x_forwarded_for;
+        proxy_pass       http://10.130.128.3:28132;
+    }
+    error_page           500   502            503 504 403 404 405 301 /50x.html;
+    location = /50x.html {
+        root html;
+    }
+}

+ 1 - 1
vue.config.js

@@ -6,7 +6,7 @@ const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
 
 module.exports = defineConfig({
   transpileDependencies: true,
-  publicPath: '/',
+  publicPath: '/sddnWeihe',
   assetsDir: 'static',
   outputDir: 'dist',
   lintOnSave: false, // 是否开启eslint