feat(deploy): 阿里云ECS+1Panel 服务器部署方案落地

- docker-compose.server.yml:生产编排(复用 1Panel MySQL、去 mysql/redis、
  端口仅绑 127.0.0.1、TZ=Asia/Shanghai、MYSQL_HOST 必填守卫)
- 两份 Dockerfile 内置国内构建源:apt/pip→阿里云,npm/playwright→npmmirror
  (ECS 上直连官方源慢/超时;对本地构建同样可用)
- DEPLOY.md 重写为 v2 runbook:单站点反代架构、mysqldump+media 搬迁管道
  (ngram 索引导入重建 ~12min)、验收清单、运维表、本地停 scheduler 收尾

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-01 16:30:46 +08:00
parent 9ba8063ca8
commit 974929e091
4 changed files with 261 additions and 139 deletions
+10 -1
View File
@@ -11,6 +11,11 @@ FROM python:3.12-slim
# cryptography.``libmariadb`` is what asyncmy links against on Debian.
# Playwright 系统依赖:Chromium headless 需要的共享库(libnss3/libatk/libx11
# 等,playwright install-deps 的等价精简集,2026-08-21 部署阻塞点#1)。
# 国内构建加速(阿里云 ECS 上 apt/pip 直连官方源慢或超时;对本地构建同样
# 可用,镜像源无地域限制)。bookworm/trixie 的源都在 debian.sources 里;
# 文件不存在(更老基础镜像)则跳过,不影响构建。
RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || true
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
@@ -61,7 +66,11 @@ COPY migrations/ ./migrations/
# Install the package + dev dependencies (the dev extras include aiosqlite +
# pytest, which are tiny and convenient for in-container smoke checks). Pin
# the install to the local source so the package import path resolves.
RUN pip install --no-cache-dir -e ".[dev]" \
# 国内构建加速:pip 走阿里云源;Chromium 二进制(~160MB)走 npmmirror,
# 否则 ECS 上从 playwright CDN 下载很慢。
ENV PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright
RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ -e ".[dev]" \
&& playwright install chromium --with-deps
# Default command — overridden per-service in docker-compose. The API service