From 191587346c86644e2f978f59e3858fb74eb1103d Mon Sep 17 00:00:00 2001 From: Samuel GIFFARD Date: Tue, 28 Jan 2025 09:51:16 +0100 Subject: [PATCH] Fix macOS startup (#4658) ### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/4319 This pull request includes several changes to improve the Docker setup and documentation for the project. The most important changes include updating the Dockerfile to support modern versions of Rust, adding a new Docker Compose configuration for macOS, and updating the build instructions in the documentation. Improvements to Docker setup: * [`Dockerfile`](diffhunk://#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557L80-R107): Added installation steps for a modern version of Rust and updated the logic for installing the correct ODBC driver based on the architecture. * [`docker/docker-compose-macos.yml`](diffhunk://#diff-8e8587143bb2442c02f6dff4caa217ebbe3ba4ec8e7c23b2e568886a67b00eafR1-R56): Added a new Docker Compose configuration file specifically for macOS, including service dependencies, environment variables, and volume mappings. Updates to documentation: * [`docs/guides/develop/build_docker_image.mdx`](diffhunk://#diff-d6136bb897f7245aae33b0accbcf7c508ceaef005c545f9f09cad3cada840a19L44-R44): Updated the build instructions to use the new Docker Compose configuration for macOS instead of the previous Docker build command. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] Documentation Update --------- Signed-off-by: Samuel Giffard --- Dockerfile | 28 ++++++++--- docker/docker-compose-macos.yml | 56 ++++++++++++++++++++++ docs/guides/develop/build_docker_image.mdx | 2 +- 3 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 docker/docker-compose-macos.yml diff --git a/Dockerfile b/Dockerfile index a78beeab3..00e3d4f55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,11 +77,26 @@ ENV PATH=/root/.local/bin:$PATH # nodejs 12.22 on Ubuntu 22.04 is too old RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \ curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ - apt purge -y nodejs npm && \ - apt autoremove && \ + apt purge -y nodejs npm cargo && \ + apt autoremove -y && \ apt update && \ - apt install -y nodejs cargo + apt install -y nodejs +# A modern version of cargo is needed for the latest version of the Rust compiler. +RUN apt update && apt install -y curl build-essential \ + && if [ "$NEED_MIRROR" == "1" ]; then \ + # Use TUNA mirrors for rustup/rust dist files + export RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup"; \ + export RUSTUP_UPDATE_ROOT="https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup"; \ + echo "Using TUNA mirrors for Rustup."; \ + fi; \ + # Force curl to use HTTP/1.1 + curl --proto '=https' --tlsv1.2 --http1.1 -sSf https://sh.rustup.rs | bash -s -- -y --profile minimal \ + && echo 'export PATH="/root/.cargo/bin:${PATH}"' >> /root/.bashrc + +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN cargo --version && rustc --version # Add msssql ODBC driver # macOS ARM64 environment, install msodbcsql18. @@ -90,11 +105,12 @@ RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \ curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ apt update && \ - if [ -n "$ARCH" ] && [ "$ARCH" = "arm64" ]; then \ - # MacOS ARM64 + arch="$(uname -m)"; \ + if [ "$arch" = "arm64" ] || [ "$arch" = "aarch64" ]; then \ + # ARM64 (macOS/Apple Silicon or Linux aarch64) ACCEPT_EULA=Y apt install -y unixodbc-dev msodbcsql18; \ else \ - # (x86_64) + # x86_64 or others ACCEPT_EULA=Y apt install -y unixodbc-dev msodbcsql17; \ fi || \ { echo "Failed to install ODBC driver"; exit 1; } diff --git a/docker/docker-compose-macos.yml b/docker/docker-compose-macos.yml new file mode 100644 index 000000000..4862c0e2b --- /dev/null +++ b/docker/docker-compose-macos.yml @@ -0,0 +1,56 @@ +include: + - ./docker-compose-base.yml + +services: + ragflow: + depends_on: + mysql: + condition: service_healthy + build: + context: ../ + dockerfile: Dockerfile + container_name: ragflow-server + ports: + - ${SVR_HTTP_PORT}:9380 + - 80:80 + - 443:443 + volumes: + - ./ragflow-logs:/ragflow/logs + - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf + - ./nginx/proxy.conf:/etc/nginx/proxy.conf + - ./nginx/nginx.conf:/etc/nginx/nginx.conf + env_file: .env + environment: + - TZ=${TIMEZONE} + - HF_ENDPOINT=${HF_ENDPOINT} + - MACOS=${MACOS:-1} + - LIGHTEN=${LIGHTEN:-1} + networks: + - ragflow + restart: on-failure + # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration + # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. + extra_hosts: + - "host.docker.internal:host-gateway" + # executor: + # depends_on: + # mysql: + # condition: service_healthy + # image: ${RAGFLOW_IMAGE} + # container_name: ragflow-executor + # volumes: + # - ./ragflow-logs:/ragflow/logs + # - ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf + # env_file: .env + # environment: + # - TZ=${TIMEZONE} + # - HF_ENDPOINT=${HF_ENDPOINT} + # - MACOS=${MACOS} + # entrypoint: "/ragflow/entrypoint_task_executor.sh 1 3" + # networks: + # - ragflow + # restart: on-failure + # # https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration + # # If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container. + # extra_hosts: + # - "host.docker.internal:host-gateway" diff --git a/docs/guides/develop/build_docker_image.mdx b/docs/guides/develop/build_docker_image.mdx index 91f06fcf3..7f2559ab3 100644 --- a/docs/guides/develop/build_docker_image.mdx +++ b/docs/guides/develop/build_docker_image.mdx @@ -41,7 +41,7 @@ While we also test RAGFlow on ARM64 platforms, we do not plan to maintain RAGFlo ```bash git clone https://github.com/infiniflow/ragflow.git cd ragflow/ -docker build --build-arg LIGHTEN=1 -f Dockerfile -t infiniflow/ragflow:nightly-slim . +docker compose -f docker/docker-compose-macos.yml up -d ```