From 8a9ee6ab11f211129c381e32df038fd60951aac2 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 9 Jul 2026 14:00:22 +0800 Subject: [PATCH] =?UTF-8?q?ci(P2-8):=20=E4=BC=98=E5=8C=96api.Dockerfile?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E4=BD=93=E7=A7=AF=EF=BC=8C=E6=B8=85=E7=90=86?= =?UTF-8?q?Python=E5=AD=97=E8=8A=82=E7=A0=81=E5=92=8Capt=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/docker/api.Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/infra/docker/api.Dockerfile b/infra/docker/api.Dockerfile index 7c280c190..1ba93519e 100755 --- a/infra/docker/api.Dockerfile +++ b/infra/docker/api.Dockerfile @@ -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