# 构建阶段
FROM oven/bun:1.1.13-alpine AS builder

WORKDIR /app

# 拷贝依赖文件
COPY package.json bun.lock* ./

# 安装依赖
RUN bun install

# 拷贝全部源代码
COPY . .
# 拷贝生产环境配置
COPY .env.production .env

# 构建前端
RUN bun run build

# 生产环境阶段
FROM nginx:alpine

# 拷贝构建产物到 nginx 静态目录
COPY --from=builder /app/dist /usr/share/nginx/html

# 启用自定义 nginx 配置
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"] 