- deploy/Dockerfile:多阶段构建,node:24-alpine(阿里镜像)构建 dist,nginx:alpine 作为成品镜像;构建上下文为仓库根目录 - deploy/nginx.conf:Vue Router history 模式 SPA 配置,含 gzip 压缩和 /assets/ 长期缓存 - deploy/compose.yaml:以 zhican-admin:latest 启动服务,对外暴露 12801 端口 - .teamcity/pipeline.yaml:main 分支触发,build/deploy 独立 step Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
827 B
Nginx Configuration File
35 lines
827 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Vue Router history 模式:所有未匹配的路径回落到 index.html
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Vite 构建产物带 hash,可安全设置长期缓存
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# gzip 压缩
|
|
gzip on;
|
|
gzip_min_length 1024;
|
|
gzip_comp_level 6;
|
|
gzip_types
|
|
text/plain
|
|
text/css
|
|
text/javascript
|
|
application/javascript
|
|
application/json
|
|
application/xml
|
|
image/svg+xml;
|
|
|
|
# 基础安全头
|
|
add_header X-Content-Type-Options "nosniff";
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
}
|