优化 Dockerfile

This commit is contained in:
2025-11-10 17:14:15 +08:00
parent 428b5762d2
commit f8ed0ef3c0
3 changed files with 87 additions and 29 deletions

View File

@@ -13,29 +13,8 @@ USER root
WORKDIR /ragflow
# Set UV HTTP timeout to handle large package downloads (e.g., nvidia-cusolver-cu12)
# Default is 30s, increase to 600s (10 minutes) for large packages
ENV UV_HTTP_TIMEOUT=600
# install dependencies from pyproject.toml
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
RUN --mount=type=cache,id=ragflow_uv,target=/root/.cache/uv,sharing=locked \
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
# Python dependencies are already installed in base image
# Build web application
COPY web web
COPY docs docs
RUN --mount=type=cache,id=ragflow_npm,target=/root/.npm,sharing=locked \
@@ -58,11 +37,7 @@ USER root
WORKDIR /ragflow
# Copy Python environment and packages
ENV VIRTUAL_ENV=/ragflow/.venv
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
# Python environment is already set up in base image
ENV PYTHONPATH=/ragflow/
COPY web web