6044b00685
- 上游 Key 命名改为 {prefix}-{upstream.id}-{safe_group_name}-{group_id}
- 唯一约束 (upstream_id, group_id, managed_prefix) 加 managed_prefix 列
- 上游检测成功时同步 Key 状态,远端已删/分组已删自动清理
- 重复分组导入跳过,目标网站已存在同名分组返回 exists
- 账号导入平台自动识别(auto/manual 模式)
- 全选可导入 Key 按钮 + 目标分组自动匹配
- 导入幂等:已导入过的 Key 校验远端账号,不存在则重建
- 新增同步接口 POST /sync-imported-upstream-keys
- account_exists() 通过拉取账号列表判断,避免 404 误判
- credentials.base_url 注入来源上游地址,避免 401
- 前端导入弹窗自动同步+刷新按钮+并发/优先级设置
- 新增 12 个测试覆盖同步、幂等、远端删除、校验失败路径
61 lines
2.1 KiB
Docker
61 lines
2.1 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# ---- Stage 1: Build frontend ----
|
|
FROM node:20-alpine AS frontend-build
|
|
WORKDIR /frontend
|
|
|
|
# 依赖层:package*.json 不变则复用 npm 缓存
|
|
COPY frontend/package*.json ./
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci --registry=https://registry.npmmirror.com
|
|
|
|
# 源码层:业务代码变更不影响上层依赖
|
|
COPY frontend/ .
|
|
RUN npm run build
|
|
|
|
# ---- Stage 2: Python backend ----
|
|
FROM python:3.12-slim
|
|
WORKDIR /app
|
|
|
|
ENV PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright
|
|
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
|
|
|
RUN sed -i 's|http://deb.debian.org|https://mirrors.aliyun.com|g; s|http://security.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources
|
|
|
|
# 系统依赖层:apt 包安装,缓存 deb 包避免重复下载
|
|
RUN --mount=type=cache,target=/var/cache/apt \
|
|
apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
fonts-liberation fonts-unifont fonts-wqy-zenhei \
|
|
libasound2t64 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 \
|
|
libcairo2 libcups2 libdbus-1-3 libdrm2 libegl1 libfontconfig1 \
|
|
libfreetype6 libgbm1 libglib2.0-0t64 libgtk-3-0t64 libnspr4 libnss3 \
|
|
libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
|
|
libxdamage1 libxext6 libxfixes3 libxrandr2 libxshmfence1 xvfb \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Python 依赖层:requirements.txt 不变则复用 pip 缓存
|
|
COPY backend/requirements.txt .
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple \
|
|
--trusted-host pypi.tuna.tsinghua.edu.cn \
|
|
-r requirements.txt
|
|
|
|
# Playwright Chromium:安装在镜像层中,业务代码变更不会触发重下
|
|
RUN playwright install chromium
|
|
|
|
# 源码层:业务代码变更不影响上面所有依赖层
|
|
COPY backend/ .
|
|
|
|
# 前端构建产物
|
|
COPY --from=frontend-build /frontend/dist ./static
|
|
|
|
RUN mkdir -p /app/data
|
|
|
|
ENV PYTHONPATH=/app
|
|
ENV DATABASE_URL=sqlite:////app/data/app.db
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|