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