diff --git a/.env.production b/.env.production index d9d4379..d6f909b 100644 --- a/.env.production +++ b/.env.production @@ -1,12 +1,3 @@ #后台地址 VITE_GLOB_API_URL=https://api.xjygjk.com -#健康监测工具报警-websocket -VITE_GLOB_API_YIN_JI=wss://api.xjygjk.com/health-watch/websocket/watchMonitor -#应急求助-websocket -VITE_GLOB_API_JIAN_CE=wss://api.xjygjk.com/health-emergency/websocket/emergency - -#西安云坐席 -VITE_GLOB_API_XIAN_YUN=wss://api.xjygjk.com/health-emergency/websocket/emergency3 -#银川云坐席 -VITE_GLOB_API_YIN_CHUAN=wss://api.xjygjk.com/health-emergency/websocket/emergency4 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 36018e4..703afe3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,9 @@ FROM nginx MAINTAINER jeecgos@163.com VOLUME /tmp ENV LANG en_US.UTF-8 + +ENV VITE_GLOB_API_URL https://api.xjygjk.com + RUN echo "server { \ #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 \ location / { \ @@ -18,4 +21,12 @@ RUN echo "server { \ && mkdir -p /var/www/html ADD dist/ /var/www/html/ -EXPOSE 3101 + +# 👇 新增:复制启动脚本(用于运行时替换环境变量) +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# 使用脚本作为入口点 +ENTRYPOINT ["/entrypoint.sh"] + +EXPOSE 80 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..2514ee0 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# 设置默认值(构建时 .env 不生效时兜底) +: ${VITE_GLOB_API_URL:=https://api.xjygjk.com} + +# 替换 index.html 中的占位符 +sed -i "s@__VITE_GLOB_API_URL__@$VITE_GLOB_API_URL@g" /var/www/html/index.html + +exec nginx -g 'daemon off;' \ No newline at end of file diff --git a/index.html b/index.html index 742dbf3..37395f8 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,10 @@ 应急就医服务中心