Files
archived-gitea-ai-assistant/Dockerfile
accelerator b4feb0a822 ci: 添加GitHub Actions CI/CD流水线
- CI: PR触发自动化测试(lint + type check + bun test)
- CD: push到main/tag触发Docker镜像构建并发布到GHCR
- 修复Dockerfile中bun.lockb→bun.lock引用
- 修复tsconfig.json排除测试文件避免dist中重复
- 修复file-review-store测试排序时间戳竞态
2026-03-01 14:47:22 +08:00

53 lines
1.1 KiB
Docker

# ---- Stage 1: Frontend Builder ----
FROM oven/bun:1 as frontend-builder
WORKDIR /app/frontend
# 拷贝前端的 package.json 和 lockfile
COPY frontend/package.json frontend/bun.lock* ./
# 安装前端依赖
RUN bun install --frozen-lockfile
# 拷贝所有前端代码
COPY frontend/ .
# 构建前端静态文件
RUN bun run build
# ---- Stage 2: Backend Builder ----
FROM oven/bun:1 as backend-builder
WORKDIR /app
# 拷贝后端的 package.json 和 lockfile
COPY package.json bun.lock* ./
# 只安装生产环境依赖
RUN bun install --frozen-lockfile --production
# 拷贝所有后端代码
COPY src ./src
COPY tsconfig.json .
# ---- Stage 3: Production ----
FROM oven/bun:1-slim
WORKDIR /app
# 从后端构建器拷贝依赖和代码
COPY --from=backend-builder /app/node_modules ./node_modules
COPY --from=backend-builder /app/src ./src
COPY --from=backend-builder /app/package.json .
COPY --from=backend-builder /app/tsconfig.json .
# 从前端构建器拷贝构建好的静态文件到 public 目录
COPY --from=frontend-builder /app/frontend/dist ./public
EXPOSE 3000
# 启动服务
CMD ["bun", "run", "start"]