From a99af4d2d7057991c2706629a3cee987b32fc2fd Mon Sep 17 00:00:00 2001 From: zong Date: Wed, 3 Sep 2025 14:52:47 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8A=A0=E5=85=A5docker=20file=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=202.=E8=AA=BF=E6=95=B4=E7=B5=84=E4=BB=B6=E4=BB=A5?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20window.env=20=E8=AE=80=E5=8F=96=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E8=AE=8A=E6=95=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 7 +++ .env.development | 4 -- .env.production | 4 -- .env.staging | 3 -- .gitattributes | 2 - Dockerfile | 43 +++++++++++++++++++ docker-entrypoint.sh | 5 +++ index.html | 1 + src/apis/account/index.js | 2 +- src/apis/alert/index.js | 2 +- src/apis/asset/index.js | 2 +- src/apis/building/index.js | 2 +- src/apis/dashboard/index.js | 2 +- src/apis/energy/index.js | 2 +- src/apis/forge/index.js | 2 +- src/apis/graph/api.js | 2 +- src/apis/history/api.js | 2 +- src/apis/login/index.js | 2 +- src/apis/operation/index.js | 2 +- src/apis/productSetting/index.js | 2 +- src/apis/system/index.js | 2 +- src/components/forge/Forge.vue | 2 +- src/components/forge/ForgeForSystem.vue | 2 +- src/constant/api_app.js | 2 +- src/constant/api_forge.js | 2 +- src/main.js | 2 +- src/util/downloadExcel.js | 2 +- src/util/request.js | 2 +- .../AssetManagement/components/AssetTable.vue | 2 +- .../components/AssetTableModalLeftInfo.vue | 2 +- .../AssetTableModalLeftInfoGraph.vue | 2 +- .../components/AssetTableModalRightInfo.vue | 2 +- .../components/AlertQuery/AlertTableModal.vue | 2 +- src/views/dashboard/Dashboard.vue | 2 +- .../components/DashboardEffectScatter.vue | 2 +- .../dashboard/components/DashboardSysCard.vue | 2 +- .../graphManagement/components/GraphModal.vue | 2 +- .../graphManagement/components/GraphTable.vue | 2 +- .../operation/components/OperationTable.vue | 2 +- .../components/OperationTableModal.vue | 2 +- src/views/setting/components/Floors.vue | 2 +- src/views/system/SystemFloor.vue | 2 +- src/views/system/components/SystemCard.vue | 2 +- .../components/SystemInfoModalImage.vue | 2 +- vite.config.js | 9 ---- 45 files changed, 92 insertions(+), 58 deletions(-) create mode 100644 .dockerignore delete mode 100644 .env.development delete mode 100644 .env.production delete mode 100644 .env.staging delete mode 100644 .gitattributes create mode 100644 Dockerfile create mode 100644 docker-entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..415d6a2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +.git +.gitignore +Dockerfile +docker-compose.yml +README.md +.vs \ No newline at end of file diff --git a/.env.development b/.env.development deleted file mode 100644 index c3ed821..0000000 --- a/.env.development +++ /dev/null @@ -1,4 +0,0 @@ -VITE_API_BASEURL = "https://ibms-Empower-api.production.mjmtech.com.tw" -VITE_FILE_API_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw" -VITE_MQTT_BASEURL = "wss://mqttwss.mjm-staging.developers-homelab.net" -VITE_FORGE_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw/dist" \ No newline at end of file diff --git a/.env.production b/.env.production deleted file mode 100644 index c3ed821..0000000 --- a/.env.production +++ /dev/null @@ -1,4 +0,0 @@ -VITE_API_BASEURL = "https://ibms-Empower-api.production.mjmtech.com.tw" -VITE_FILE_API_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw" -VITE_MQTT_BASEURL = "wss://mqttwss.mjm-staging.developers-homelab.net" -VITE_FORGE_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw/dist" \ No newline at end of file diff --git a/.env.staging b/.env.staging deleted file mode 100644 index 3a51cfe..0000000 --- a/.env.staging +++ /dev/null @@ -1,3 +0,0 @@ -VITE_API_BASEURL = "http://220.132.206.5:8008" -VITE_FILE_API_BASEURL = "http://220.132.206.5:8085/file" -VITE_FORGE_BASEURL = "http://localhost:5173" \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b6565d2..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -* text=auto -*.html text eol=lf \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..23cc02a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ + # 使用 Node.js 作為基礎映像 +FROM node:18-alpine AS builder + +# 設定工作目錄 +WORKDIR /app + +# 複製 package.json 和 package-lock.json (或 yarn.lock) 到工作目錄 +COPY package*.json ./ + +# 安裝依賴 +RUN npm install --legacy-peer-deps + +# 複製所有檔案到工作目錄 +COPY . . + +# 清理緩存並重新構建 +RUN npm cache clean --force +RUN rm -rf node_modules +RUN npm install --legacy-peer-deps + +# 構建前端應用 (如果需要) +RUN npm run build --omit=dev + +# 使用一個更小的映像來提供靜態文件 (例如 Nginx) +FROM nginx:alpine + +# 將構建好的靜態檔案複製到 Nginx 的預設目錄 +COPY --from=builder /app/dist /usr/share/nginx/html + +# (可選) 複製自定義 Nginx 設定檔 +# COPY nginx.conf /etc/nginx/conf.d/default.conf + +# 暴露 Nginx 預設的 80 端口 +EXPOSE 80 + +# 2025-08-29 說明 +LABEL changelog="2025-08-29: 打包測試。" + +# Nginx 已經預設啟動,所以不需要 CMD 指令 +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..21d4d1f --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "window.env = { VITE_API_BASEURL: '${VITE_API_BASEURL}', VITE_FILE_API_BASEURL: '${VITE_FILE_API_BASEURL}', VITE_APP_TITLE: '${VITE_APP_TITLE}' };" > /usr/share/nginx/html/env.js +sed -i "s|.*|${VITE_APP_TITLE}|g" /usr/share/nginx/html/index.html +sed -i "s| 新創賦能 + diff --git a/src/apis/account/index.js b/src/apis/account/index.js index 210b375..f2f8454 100644 --- a/src/apis/account/index.js +++ b/src/apis/account/index.js @@ -10,7 +10,7 @@ import { DELETE_ACCOUNT_USER_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getAccountUserList = async (search_condition = {}) => { const res = await instance.post(GET_ACCOUNT_USERLIST_API, search_condition); diff --git a/src/apis/alert/index.js b/src/apis/alert/index.js index d2f19e3..1e6a848 100644 --- a/src/apis/alert/index.js +++ b/src/apis/alert/index.js @@ -23,7 +23,7 @@ import { POST_ALERT_MQTT_REFRESH, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getAlertFormId = async (uuid) => { const res = await instance.post(GET_ALERT_FORMID_API, uuid); diff --git a/src/apis/asset/index.js b/src/apis/asset/index.js index e124482..adb52d1 100644 --- a/src/apis/asset/index.js +++ b/src/apis/asset/index.js @@ -28,7 +28,7 @@ import { POST_ASSET_ELEC_SETTING_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import { object } from "yup"; export const getAssetMainList = async (building_guid) => { diff --git a/src/apis/building/index.js b/src/apis/building/index.js index 0c3579e..e726f1e 100644 --- a/src/apis/building/index.js +++ b/src/apis/building/index.js @@ -7,7 +7,7 @@ import { GET_ALL_DEVICE_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getBuildings = async () => { const res = await instance.post(GET_BUILDING_API); diff --git a/src/apis/dashboard/index.js b/src/apis/dashboard/index.js index b6bc297..7c44474 100644 --- a/src/apis/dashboard/index.js +++ b/src/apis/dashboard/index.js @@ -13,7 +13,7 @@ import { GET_DASHBOARD_ALARMOPERATION_INFO_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getDashboardInit = async (page_type = "SR") => { const res = await instance.post(GET_DASHBOARD_INIT_API, { diff --git a/src/apis/energy/index.js b/src/apis/energy/index.js index b739a40..dfaaab0 100644 --- a/src/apis/energy/index.js +++ b/src/apis/energy/index.js @@ -18,7 +18,7 @@ import { POST_TIME_ELEC_API, } from "./api"; import instance, { fileInstance } from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import downloadExcel from "@/util/downloadExcel"; export const getRealTimeData = async () => { diff --git a/src/apis/forge/index.js b/src/apis/forge/index.js index d13d4bb..1100b39 100644 --- a/src/apis/forge/index.js +++ b/src/apis/forge/index.js @@ -1,6 +1,6 @@ import instance from "@/util/request"; import { GET_FORGETOKEN_API, GET_FORGEURN_API } from "./api"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getUrn = async () => { const res = await instance.post(GET_FORGEURN_API); diff --git a/src/apis/graph/api.js b/src/apis/graph/api.js index 427ae7c..73f513b 100644 --- a/src/apis/graph/api.js +++ b/src/apis/graph/api.js @@ -1,5 +1,5 @@ // graph -const BASEURL = import.meta.env.VITE_API_BASEURL; +const BASEURL = window.env?.VITE_API_BASEURL; export const GET_GRAPH_SIDEBAR_API = `/GraphManage/GraphManageTreeList`; export const UPDATE_GRAPH_SIDEBAR_API = `/GraphManage/EditGraphManageTree`; diff --git a/src/apis/history/api.js b/src/apis/history/api.js index 64de717..c0fd361 100644 --- a/src/apis/history/api.js +++ b/src/apis/history/api.js @@ -1,5 +1,5 @@ // history -const BASEURL = import.meta.env.VITE_API_BASEURL; +const BASEURL = window.env?.VITE_API_BASEURL; export const GET_HISTORY_SIDEBAR_API = `/api/History/GetDeviceInfo`; export const GET_HISTORY_POINT_API = `/api/History/GetAllDevPoi`; export const GET_HISTORY_DATA_API = `/api/History/GetHistoryData`; diff --git a/src/apis/login/index.js b/src/apis/login/index.js index 2bb6498..f2bd9e6 100644 --- a/src/apis/login/index.js +++ b/src/apis/login/index.js @@ -1,6 +1,6 @@ import { POST_LOGIN } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export async function Login({ account, password }) { const res = await instance.post(POST_LOGIN, { diff --git a/src/apis/operation/index.js b/src/apis/operation/index.js index c7c9d1b..9a42892 100644 --- a/src/apis/operation/index.js +++ b/src/apis/operation/index.js @@ -12,7 +12,7 @@ import { DELETE_OPERATION_COMPANY_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import dayjs from "dayjs"; export const getOperationRecord = async ({ diff --git a/src/apis/productSetting/index.js b/src/apis/productSetting/index.js index 1ed4d46..d811279 100644 --- a/src/apis/productSetting/index.js +++ b/src/apis/productSetting/index.js @@ -1,5 +1,5 @@ import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import { POST_SETTING_POINT_API, GET_SETTING_TYPE_API, diff --git a/src/apis/system/index.js b/src/apis/system/index.js index 9756bdc..26d4448 100644 --- a/src/apis/system/index.js +++ b/src/apis/system/index.js @@ -7,7 +7,7 @@ import { POST_MQTT_TOPIC_STOP_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getSystemFloors = async (building_tag, sub_system_tag) => { const res = await instance.post(GET_SYSTEM_FLOOR_LIST_API, { diff --git a/src/components/forge/Forge.vue b/src/components/forge/Forge.vue index e55b62d..49d4d58 100644 --- a/src/components/forge/Forge.vue +++ b/src/components/forge/Forge.vue @@ -1,7 +1,7 @@