Files
ai-platform/Dockerfile
T

30 lines
802 B
Docker
Raw 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.
# ── Stage 1: Build ──────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
# 先复制依赖描述文件,利用 Docker 缓存层
COPY package.json package-lock.json* ./
# 安装依赖
RUN npm install
# 复制源码
COPY . .
# 构建生产包(tsc + vite build → dist/)
RUN npm run build
# ── Stage 2: Serve ──────────────────────────────────
FROM nginx:alpine
# 将构建产物复制到 Nginx 默认静态目录
COPY --from=builder /app/dist /usr/share/nginx/html
# 自定义 Nginx 配置:支持 SPA 路由 fallback + gzip
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]