docker-compose-gpu.yml


Overview

This docker-compose-gpu.yml file is a Docker Compose configuration designed to deploy the RAGFlow server with GPU support. It extends a base Docker Compose file (docker-compose-base.yml) and configures the RAGFlow service to run within a containerized environment that leverages NVIDIA GPUs for hardware acceleration. It also integrates necessary services, networking, volumes, and environment configurations required for RAGFlow to operate properly in a GPU-enabled Docker setup.

Important Note:
The RAGFlow team does not actively maintain this file, and users are advised to use it at their own risk. Contributions via pull requests are welcome to improve it.


Detailed Explanation

File Structure and Components

The file is structured to define one main service (ragflow) that depends on a MySQL database service and includes GPU resource reservations. It also incorporates external configuration files, environment variables, and Docker networking.

include:
  - ./docker-compose-base.yml

Service: ragflow

This is the primary service defined in this file. It represents the RAGFlow server container configured to utilize NVIDIA GPUs.

Property

Description

depends_on

Specifies service dependencies. Here, ragflow depends on the mysql service and waits until it is healthy before starting.

image

Docker image to use for the ragflow container, specified by the environment variable ${RAGFLOW_IMAGE}.

container_name

Sets the container name to ragflow-server for easier reference.

ports

Maps host ports to container ports:
- ${SVR_HTTP_PORT}9380 (RAGFlow internal port)
- 80 and 443 for HTTP and HTTPS traffic.

volumes

Mounts local directories and files into the container:
- ./ragflow-logs/ragflow/logs (logs directory)
- Nginx configuration files for reverse proxy setup (ragflow.conf, proxy.conf, nginx.conf).

env_file

Loads environment variables from a .env file.

environment

Additional environment variables:
- TZ (timezone)
- HF_ENDPOINT (endpoint for Hugging Face or similar services)
- MACOS (flag indicating if running on macOS)

networks

Connects the container to the ragflow Docker network.

restart

Configured to restart the container on failure.

extra_hosts

Adds an entry host.docker.internal pointing to the Docker host gateway for container-host communication, useful for monitoring and Prometheus integration.

deploy.resources.reservations.devices

Reserves GPU devices for this container using the NVIDIA Docker runtime, requesting access to all GPUs (count: all) with gpu capability.


Key Implementation Details


Usage Example

Assuming you have the necessary environment variables set in your .env file and the base compose file present, you can start the GPU-enabled RAGFlow stack with:

docker-compose -f docker-compose-gpu.yml up -d

This command will:


Interaction with Other Parts of the System


Mermaid Diagram: Service Dependency and Configuration Flow

flowchart TD
    A[Start Docker Compose GPU Setup] --> B[Include docker-compose-base.yml]
    B --> C[Start mysql service]
    C -->|Wait until healthy| D[Start ragflow service]
    D --> E{Configure ragflow service}
    E --> F[Set image: ${RAGFLOW_IMAGE}]
    E --> G[Expose ports: ${SVR_HTTP_PORT}:9380, 80:80, 443:443]
    E --> H[Mount volumes for logs and nginx configs]
    E --> I[Load env vars from .env and environment block]
    E --> J[Connect to ragflow network]
    E --> K[Set restart policy: on-failure]
    E --> L[Add extra_hosts: host.docker.internal]
    E --> M[Reserve GPU devices with NVIDIA driver]

Summary


This documentation should help developers and DevOps engineers understand, maintain, and extend the GPU-enabled RAGFlow Docker deployment.