ci(P2-8): 优化api.Dockerfile镜像体积,清理Python字节码和apt缓存

This commit is contained in:
2026-07-09 14:00:22 +08:00
parent bf2649e445
commit 8a9ee6ab11
+3
View File
@@ -39,6 +39,9 @@ COPY migrations/ /app/migrations/
COPY alembic/ /app/alembic/
COPY scripts/ /app/scripts/
# 清理不需要的文件,减小镜像体积
RUN find /app -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true && find /opt/venv -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true && find /opt/venv -name "*.pyc" -delete 2>/dev/null || true && find /opt/venv -name "*.pyo" -delete 2>/dev/null || true && rm -rf /opt/venv/share/doc /opt/venv/share/man 2>/dev/null || true && apt-get clean && rm -rf /var/lib/apt/lists/*
# 设置环境变量
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONPATH=/app