优化 Dockerfile构建

This commit is contained in:
2025-11-19 10:45:38 +08:00
parent 206d621662
commit 067ef5406f
2 changed files with 37 additions and 31 deletions

View File

@@ -137,31 +137,3 @@ RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/,target=/deps
dpkg -i /deps/libssl1.1_1.1.1f-1ubuntu2_arm64.deb; \
fi
# Install Python dependencies from pyproject.toml
# This is done in base image since dependencies don't change frequently
COPY pyproject.toml ./
# https://github.com/astral-sh/uv/issues/10462
# uv records index url into uv.lock but doesn't failover among multiple indexes
# Generate uv.lock from pyproject.toml and install dependencies with cache
# Set UV HTTP timeout based on mirror usage:
# - With mirror (NEED_MIRROR=1): 600s for potentially slower mirror connections
# - Without mirror (abroad): 300s should be sufficient for PyPI with good network
RUN --mount=type=cache,id=ragflow_uv,target=/root/.cache/uv,sharing=locked \
export UV_HTTP_TIMEOUT=$([ "$NEED_MIRROR" == "1" ] && echo "600" || echo "300") && \
if [ "$NEED_MIRROR" == "1" ]; then \
uv lock --index-url https://mirrors.aliyun.com/pypi/simple; \
sed -i 's|pypi.org|mirrors.aliyun.com/pypi|g' uv.lock; \
else \
uv lock; \
sed -i 's|mirrors.aliyun.com/pypi|pypi.org|g' uv.lock; \
fi && \
if [ "$LIGHTEN" == "1" ]; then \
uv sync --python 3.10 --frozen; \
else \
uv sync --python 3.10 --frozen --all-extras; \
fi
# Set Python environment variables
ENV VIRTUAL_ENV=/ragflow/.venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"