Fundamental_Analysis/services/data-persistence-service/Dockerfile
Lv, Qi 0c975bb8f1 Refactor: Remove legacy analysis results and implement workflow history
- **Common Contracts**: Updated DTOs and models to support workflow history; removed legacy analysis result DTOs.
- **Data Persistence Service**:
    - Removed `analysis_results` table logic and API endpoints.
    - Implemented `workflow_history` API and DB access (`history.rs`).
    - Fixed compilation errors and updated tests.
    - Exposed Postgres port in `docker-compose.yml` for easier debugging/offline checks.
- **API Gateway**:
    - Implemented `history` endpoints (get history list, get by ID).
    - Removed legacy `analysis-results` endpoints.
    - Fixed routing and handler logic in `api.rs`.
- **Report Generator Service**:
    - Removed dependency on legacy `analysis-results` persistence calls.
    - Fixed compilation errors.
- **Workflow Orchestrator**: Fixed warnings and minor logic issues.
- **Providers**: Updated provider services (alphavantage, tushare, finnhub, yfinance, mock) to align with contract changes.
- **Frontend**:
    - Updated `ReportPage` and stores to use new workflow history.
    - Added `RecentReportsDropdown` component.
    - Cleaned up `RealtimeLogs` component.
- **Documentation**: Moved completed design tasks to `completed/` and added refactoring context docs.

Confirmed all services pass `cargo check`.
2025-11-29 14:46:44 +08:00

49 lines
2.3 KiB
Docker

FROM rust:1.90-bookworm AS chef
WORKDIR /app
RUN cargo install cargo-chef
FROM chef AS planner
WORKDIR /app/services/data-persistence-service
# 仅复制必要的 Cargo 清单,避免大体积上下文
COPY services/common-contracts/Cargo.toml /app/services/common-contracts/Cargo.toml
COPY crates/workflow-context/Cargo.toml /app/crates/workflow-context/Cargo.toml
COPY services/data-persistence-service/Cargo.toml /app/services/data-persistence-service/Cargo.toml
# Copy service_kit mirror for dependency resolution
COPY ref/service_kit_mirror /app/ref/service_kit_mirror
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
ENV SQLX_OFFLINE=true
WORKDIR /app/services/data-persistence-service
COPY --from=planner /app/services/data-persistence-service/recipe.json /app/services/data-persistence-service/recipe.json
# 为了支持 path 依赖,先拷贝依赖源码再 cook
ENV FORCE_REBUILD=2
COPY services/common-contracts /app/services/common-contracts
COPY crates/workflow-context /app/crates/workflow-context
# Copy service_kit mirror again for build
COPY ref/service_kit_mirror /app/ref/service_kit_mirror
RUN cargo chef cook --recipe-path /app/services/data-persistence-service/recipe.json
# 复制服务源码用于实际构建
COPY services/common-contracts /app/services/common-contracts
COPY services/data-persistence-service /app/services/data-persistence-service
## 为了在编译期通过 include_str! 嵌入根目录配置,将 /config 拷贝到 /app/config
COPY config /app/config
RUN cargo build --bin data-persistence-service-server
FROM debian:bookworm-slim AS runtime
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates libssl-dev curl && rm -rf /var/lib/apt/lists/*
RUN groupadd --system --gid 1001 appuser && \
useradd --system --uid 1001 --gid 1001 appuser
USER appuser
COPY --from=builder /app/services/data-persistence-service/target/debug/data-persistence-service-server /usr/local/bin/data-persistence-service-server
COPY services/data-persistence-service/migrations ./migrations
ENV HOST=0.0.0.0
ENV PORT=3000
## 当迁移版本发生偏差时,允许继续启动(仅容器默认;本地可覆盖)
ENV SKIP_MIGRATIONS_ON_MISMATCH=1
EXPOSE 3000
ENTRYPOINT ["/usr/local/bin/data-persistence-service-server"]