chore: 增加本地生产环境模拟调试

This commit is contained in:
RubyLiu 2023-08-04 11:37:05 +08:00 committed by fit2-zhao
parent 251e666e4b
commit b726f61708
3 changed files with 39 additions and 1 deletions

9
frontend/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM nginx:latest
COPY dist/ /app/
RUN mkdir /cnf && chown 777 /cnf
COPY nginx.conf /cnf/nginx.conf
EXPOSE 5100
WORKDIR /app
CMD [ "sh", "-c", "nginx -g 'daemon off;' -c /cnf/nginx.conf"]

28
frontend/nginx.conf Normal file
View File

@ -0,0 +1,28 @@
events {
worker_connections 1024;
}
http{
include /etc/nginx/mime.types; #文件扩展名与文件类型映射表否则前端不加载css
default_type application/octet-stream; #默认文件类型
proxy_buffer_size 128k;
proxy_buffers 32 128k;
proxy_busy_buffers_size 128k;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
server {
listen 5100;
root /app; # 工作目录是/app 这里跟Dockerfile里相同
underscores_in_headers on;
add_header X-Frame-Options "SAMEORIGIN";
try_files $uri $uri/ /index.html;
location ^~ /front/ {
proxy_pass http://172.16.200.18:8081/;
proxy_connect_timeout 2s;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
client_max_body_size 1000m;
}
}
}

View File

@ -8,6 +8,7 @@
"scripts": {
"dev": "vite --config ./config/vite.config.dev.ts",
"build": "vue-tsc --noEmit && vite build --config ./config/vite.config.prod.ts",
"build:local": "vue-tsc --noEmit && vite build --config ./config/vite.config.prod.ts --mode development",
"report": "cross-env REPORT=true npm run build",
"preview": "npm run build && vite preview --host",
"type:check": "vue-tsc --noEmit --skipLibCheck",
@ -138,4 +139,4 @@
"rollup": "^2.79.1",
"gifsicle": "5.2.0"
}
}
}