Commit c241d187 by zhangxingmin

docker 配置

parent a9f60ed6
# 页面标题
VITE_APP_TITLE = 银盾中台系统
# 测试环境配置
VITE_APP_ENV = 'testelopment'
# 若依管理系统/开发环境
VITE_APP_BASE_API = 'http://139.224.145.34:9002'
# 使用更新的基础镜像 (Debian bullseye)
FROM docker.m.daocloud.io/library/node:16-bullseye AS build
# 设置环境变量
ENV npm_config_canvas_binary_host_mirror="https://npmmirror.com/mirrors/canvas"
ENV npm_config_sharp_binary_host="https://npmmirror.com/mirrors/sharp"
ENV npm_config_sharp_libvips_binary_host="https://npmmirror.com/mirrors/sharp-libvips"
# 添加 esbuild 镜像源
ENV ESBUILD_BINARY_HOST="https://npmmirror.com/mirrors/esbuild"
# 安装系统依赖 (使用阿里云镜像源)
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
python3 \
pkg-config \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
libvips-dev \
&& rm -rf /var/lib/apt/lists/*
# 设置工作目录
WORKDIR /app
# 复制包管理文件
COPY package.json ./
# 1. 显式安装 esbuild 二进制
RUN npm install @esbuild/linux-x64 --verbose --registry=https://registry.npmmirror.com
# 2. 安装其他原生模块
RUN npm install canvas@2.11.2 --verbose --ignore-scripts
RUN npm install sharp@0.32.6 --verbose --ignore-scripts
# 3. 安装项目依赖(移除 --no-optional)
RUN npm install --verbose --registry=https://registry.npmmirror.com
# 4. 验证 esbuild 安装
RUN ls -la node_modules/esbuild/bin && \
./node_modules/.bin/esbuild --version
# 复制源码并构建
COPY . .
RUN npm run build:test
# 生产阶段
FROM docker.m.daocloud.io/library/nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 设置时区
RUN echo "https://mirrors.aliyun.com/alpine/v3.22/main/" > /etc/apk/repositories && \
echo "https://mirrors.aliyun.com/alpine/v3.22/community/" >> /etc/apk/repositories && \
apk update && \
apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
EXPOSE 6666
CMD ["nginx", "-g", "daemon off;"]
server {
listen 6666;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html; # 处理Vue路由history模式
if ($request_method = OPTIONS) {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
limit_except GET POST PUT DELETE OPTIONS {
deny all;
}
}
location ^~/ {
proxy_buffer_size 1024k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers 16 1024k; #proxy_buffers缓冲区,网页平均在32k以下的设置
proxy_busy_buffers_size 2048k; #高负荷下缓冲大小(proxy_buffers*2)
proxy_temp_file_write_size 2048k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传
proxy_pass http://139.224.145.34:9002/;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment