- Dockerfile 腾讯源 + BuildKit 缓存(backend pip / frontend npm ci),gitea 锁 1.27.1 - .dockerignore 纳入版本管理(防密钥进镜像) - 新增 migrate_prod.sh:24 个迁移分 4 批执行,含镜像新鲜度 + DB 起点校验 - cb07d6b1df01 移除 search_tsv 回填(延迟到 g0h1i2j3k4l5 统一全量回填) - 模型 journal_iso/volume/issue/pages → Text(对应迁移 95c18ebf31e4 / 55105f0bb1d7) - 搜索优化:tsvector 主路径 + COUNT 截断(10000) + pub_date 排序,admin 聚合单查询 - statement_timeout 30s→60s
44 lines
1.7 KiB
Docker
44 lines
1.7 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# 构建加速(2026-08-10):腾讯 pip/apt 源 + BuildKit pip 缓存
|
|
# 首次 build:基镜像(daemon registry-mirrors 已配腾讯)+pip 全量(腾讯源) ≈ 几分钟
|
|
# 之后代码级 build:pip 层命中缓存,只重算 COPY . . → 秒~1 分钟
|
|
|
|
# ---- Build stage ----
|
|
FROM python:3.12-slim AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
RUN sed -i 's|deb.debian.org|mirrors.tencentyun.com|g; s|security.debian.org|mirrors.tencentyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
sed -i 's|deb.debian.org|mirrors.tencentyun.com|g; s|security.debian.org|mirrors.tencentyun.com|g' /etc/apt/sources.list; \
|
|
apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN printf '[global]\nindex-url = http://mirrors.tencentyun.com/pypi/simple\ntrusted-host = mirrors.tencentyun.com\n' > /etc/pip.conf
|
|
|
|
COPY pyproject.toml .
|
|
RUN --mount=type=cache,target=/root/.cache/pip pip install .
|
|
|
|
# ---- Runtime stage ----
|
|
FROM python:3.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libpq-dev curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN groupadd -r scilit && useradd -r -g scilit -d /app -s /sbin/nologin scilit
|
|
|
|
COPY --from=builder /usr/local /usr/local
|
|
|
|
COPY . .
|
|
RUN chown -R scilit:scilit /app
|
|
|
|
USER scilit
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
|
CMD curl -sf http://localhost:8000/health || exit 1
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--proxy-headers", "--forwarded-allow-ips", "127.0.0.1,172.0.0.0/8,10.0.0.0/8", "--limit-concurrency", "256", "--timeout-keep-alive", "30", "--log-level", "warning"]
|