update
This commit is contained in:
parent
c075cea921
commit
01eaa49a8f
@ -27,6 +27,9 @@ RUN npm run build
|
||||
# 生产阶段
|
||||
FROM nginx:stable-alpine as production-stage
|
||||
|
||||
# 将自定义的 nginx 配置复制到容器中
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 将构建好的文件复制到 nginx 目录
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html/
|
||||
# 将 static 目录下的文件直接复制到网站根目录
|
||||
|
||||
25
nginx.conf
Normal file
25
nginx.conf
Normal file
@ -0,0 +1,25 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# 启用 gzip
|
||||
gzip on;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 1000;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
gzip_vary on;
|
||||
|
||||
# 支持 Vue Router 的 history 模式
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 缓存静态资源
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user