fix: add frontend build stage to Dockerfile, update npm install to include devDependencies
Build and Deploy / build (push) Successful in 2m40s
Build and Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-07-17 02:06:06 +00:00
parent 7bc8c74d5e
commit 5652012b2f
3 changed files with 2112 additions and 12 deletions
+25 -6
View File
@@ -1,5 +1,22 @@
# 构建阶段 - 使用 Debian 基础镜像
FROM golang:1.22-bookworm AS builder
# 前端构建阶段
FROM node:20-alpine AS frontend-builder
WORKDIR /app/web
# 复制前端依赖文件
COPY web/package*.json ./
# 安装依赖
RUN npm install --registry https://registry.npmmirror.com
# 复制前端源代码
COPY web/ ./
# 构建前端
RUN npm run build
# 后端构建阶段 - 使用 Debian 基础镜像
FROM golang:1.22-bookworm AS backend-builder
# 安装 OpenCV、ONNX Runtime 和编译工具
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -48,13 +65,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# 复制 ONNX Runtime
COPY --from=builder /usr/local/onnxruntime/lib/libonnxruntime.so* /usr/lib/
COPY --from=backend-builder /usr/local/onnxruntime/lib/libonnxruntime.so* /usr/lib/
WORKDIR /app
# 复制二进制文件和前端
COPY --from=builder /app/anticaptcha .
COPY --from=builder /app/web/dist ./web/dist
# 复制二进制文件
COPY --from=backend-builder /app/anticaptcha .
# 复制前端构建产物
COPY --from=frontend-builder /app/web/dist ./web/dist
# 创建数据和模型目录(模型启动时自动下载)
RUN mkdir -p /app/data /app/models
+2081
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -8,16 +8,16 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.7.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.1",
"axios": "^1.7.2"
"react-router-dom": "^6.24.1"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"typescript": "^5.5.3",
"vite": "^5.3.4"
"@vitejs/plugin-react": "^4.7.0",
"typescript": "^5.9.3",
"vite": "^5.4.21"
}
}
}