CviLux_fe/Dockerfile

43 lines
1.2 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用 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: 去掉環境變數 VITE_MQTT_BASEURL新增 MQTT 相關 API並新增總部帳戶管理初版資產管理 : 過濾無效檔案、更新資產編輯和圖表資料來源的處理邏輯。"
# Nginx 已經預設啟動,所以不需要 CMD 指令
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]