build/ci: prod发布重写

This commit is contained in:
Titan 2026-03-16 17:22:18 +08:00
parent 5bfdba9cdb
commit cb758af645
4 changed files with 42 additions and 29 deletions

View File

@ -263,29 +263,29 @@ docker-logs-gateway:
# ==========================================
# Docker Publish Command
# ==========================================
# Usage: make docker-publish VERSION=v220.20251202 SERVICE=frontend
# Example: make docker-publish VERSION=v220.20251202 SERVICE=frontend
# Usage: make docker-publish VER=v220.20251202 SVC=frontend
# Example: make docker-publish VER=v220.20251202 SVC=frontend
docker-publish:
@if [ -z "$(VERSION)" ]; then \
echo "✗ VERSION is required (e.g. v220.20251202)"; \
@if [ -z "$(VER)" ]; then \
echo "✗ VER is required (e.g. v220.20251202)"; \
exit 1; \
fi
@if [ -z "$(SERVICE)" ]; then \
echo "✗ SERVICE is required (frontend, gateway, langgraph)"; \
@if [ -z "$(SVC)" ]; then \
echo "✗ SVC is required (frontend, gateway, langgraph)"; \
exit 1; \
fi
@echo "=========================================="
@echo " Building Docker image for $(SERVICE)"
@echo " Building Docker image for $(SVC)"
@echo "=========================================="
@IMAGE=registry.xueai.art/deerflow/deerflow-$(SERVICE):$(VERSION); \
DOCKERFILE=$$(case "$(SERVICE)" in \
frontend) echo "frontend/Dockerfile";; \
@IMAGE=registry.xueai.art/deerflow/deerflow-$(SVC):$(VER); \
DOCKERFILE=$$(case "$(SVC)" in \
frontend) echo "frontend/Dockerfile.prod";; \
gateway) echo "backend/Dockerfile";; \
langgraph) echo "backend/Dockerfile";; \
*) echo "";; \
esac); \
if [ -z "$$DOCKERFILE" ]; then \
echo "✗ Unknown SERVICE: $(SERVICE)"; \
echo "✗ Unknown SVC: $(SVC)"; \
exit 1; \
fi; \
docker build -f $$DOCKERFILE -t $$IMAGE .; \

View File

@ -8,20 +8,7 @@ RUN apt-get update && apt-get install -y \
docker.io \
&& rm -rf /var/lib/apt/lists/*
# Install uv
# Use IP address for proxy (cai.local may not resolve in Docker container)
ENV http_proxy=http://192.168.1.250:7897 https_proxy=http://192.168.1.250:7897
# Exclude localhost and container network from proxy
ENV no_proxy=localhost,127.0.0.1,0.0.0.0,frontend,gateway,langgraph,nginx,.local
# RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Try to install uv via official installer, fallback to pip if fails
RUN (curl -LsSf https://astral.sh/uv/install.sh | sh || pip install uv) && \
echo "uv installed at:" && \
which uv || echo "uv not found in PATH" && \
ls -la /root/.local/bin/ || echo "/root/.local/bin/ not found" && \
echo "uv version:" && \
uv --version || echo "uv command not working"
ENV PATH="/root/.local/bin:$PATH"
RUN pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
# Set working directory
WORKDIR /app
@ -32,10 +19,7 @@ COPY backend ./backend
# Install dependencies with cache mount
RUN --mount=type=cache,target=/root/.cache/uv \
sh -c "cd backend && uv sync"
# Keep proxy for uv sync (Python package downloads may need proxy in China)
ENV http_proxy= https_proxy=
# Expose ports (gateway: 8001, langgraph: 2024)
EXPOSE 8001 2024

View File

@ -40,6 +40,7 @@ services:
gateway:
image: registry.xueai.art/deerflow/deerflow-gateway:${VERSION}
container_name: deer-flow-gateway
command: sh -c "cd backend && uv run uvicorn src.gateway.app:app --host 0.0.0.0 --port 8001 > /app/logs/gateway.log 2>&1"
volumes:
- ../config.yaml:/app/config.yaml
- ../skills:/app/skills
@ -64,6 +65,7 @@ services:
langgraph:
image: registry.xueai.art/deerflow/deerflow-langgraph:${VERSION}
container_name: deer-flow-langgraph
command: sh -c "cd backend && exec uv run langgraph dev --no-browser --no-reload --allow-blocking --host 0.0.0.0 --port 2024 > /app/logs/langgraph.log 2>&1"
volumes:
# Persist LangGraph inmem runtime data (threads/checkpoints/store)
- ../backend/.langgraph_api:/app/backend/.langgraph_api

27
frontend/Dockerfile.prod Normal file
View File

@ -0,0 +1,27 @@
# --------------- 构建阶段 ---------------
FROM node:22-alpine AS builder
ARG PNPM_STORE_PATH=/root/.local/share/pnpm/store
ENV BETTER_AUTH_SECRET=any-random-string-123456
RUN corepack enable && corepack install -g pnpm@10.26.2
RUN pnpm config set store-dir ${PNPM_STORE_PATH}
WORKDIR /app
COPY frontend/ .
RUN pnpm install --frozen-lockfile
RUN pnpm build
# --------------- 运行阶段(最小镜像) ---------------
FROM node:22-alpine AS runner
ENV NODE_ENV=production
WORKDIR /app
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
EXPOSE 3000
CMD ["pnpm", "start"]