BrianChuan
API connect Test1
54b06a9
Raw
History Blame Contribute Delete
828 Bytes
FROM node:20-alpine as build-stage
WORKDIR /app
COPY package*.json ./
# 安裝專案所有依賴
RUN npm install
# 複製其餘的所有專案原始碼 (包括 src/, public/, configs 等)
COPY . .
# 執行生產環境建置命令 (這會產生一個 dist/ 目錄)
RUN npm run build
# 使用標準的 alpine nginx 映像檔
FROM nginx:stable-alpine as production-stage
# 1. 複製階段 1 中編譯好的靜態檔案 到 Nginx 的 HTML 目錄
# Vite 預設編譯輸出的目錄是 dist/
COPY --from=build-stage /app/dist /usr/share/nginx/html
# 2. 複製我們自定義的 nginx.conf 設定檔,替換 Nginx 預設設定
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 3. 關鍵:對外開放 7860 端口 (Hugging Face Spaces 的要求)
EXPOSE 7860
# 4. 啟動 Nginx (前台運行)
CMD ["nginx", "-g", "daemon off;"]