Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# 构建阶段
|
||||
FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/node:22.15.0 AS builder
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 设置 npm 镜像源
|
||||
RUN npm config set registry https://registry.npmmirror.com/
|
||||
RUN npm config set fetch-retries 3
|
||||
RUN npm config set fetch-retry-mintimeout 5000
|
||||
RUN npm config set fetch-retry-maxtimeout 60000
|
||||
|
||||
# 安装pnpm
|
||||
RUN npm install -g pnpm@10.16.1
|
||||
|
||||
# 复制 package.json 和 pnpm-lock.yaml 文件
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# 设置 pnpm 下载源
|
||||
RUN pnpm config set registry https://registry.npmmirror.com/
|
||||
|
||||
# 安装依赖
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# 复制源代码
|
||||
COPY . .
|
||||
|
||||
# 构建项目
|
||||
RUN pnpm run build:pro
|
||||
|
||||
# 部署阶段
|
||||
FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/nginx:alpine
|
||||
|
||||
# 复制构建产物到 Nginx 目录
|
||||
COPY --from=builder --chown=nginx:nginx /app/dist /usr/share/nginx/html
|
||||
|
||||
# 复制 Nginx 配置
|
||||
COPY Dockerfiles/default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
|
||||
# 启动 Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -0,0 +1,47 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# 基础设置
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
|
||||
try_files $uri $uri/ /index.html;
|
||||
|
||||
client_max_body_size 100m;
|
||||
|
||||
# 错误页面配置
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
internal; # 仅用于内部错误请求
|
||||
}
|
||||
|
||||
# Gzip 压缩设置
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/javascript application/json
|
||||
application/javascript application/x-javascript application/xml;
|
||||
gzip_vary on;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
# 静态资源缓存优化
|
||||
location ~* \.(jpg|jpeg|gif|ico|css|js)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
|
||||
# API 代理配置
|
||||
location /api/ {
|
||||
proxy_pass http://weibingju-admin-api-svc:5566/api/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_buffering on;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user