docker-compose-gpu-CN-oc9.yml
Overview
The docker-compose-gpu-CN-oc9.yml file is a Docker Compose configuration designed to orchestrate the deployment of the RAGFlow server environment with GPU support, specifically tailored for usage in a China network context (as implied by "CN" in the filename) and possibly optimized for OpenCore 9 (oc9). This file extends a base Docker Compose configuration (docker-compose-base.yml) and specifies additional service configurations, resource reservations, and environment settings to enable GPU acceleration using NVIDIA drivers inside the container.
Key Points:
It defines the
ragflowservice, which depends on a healthymysqlservice.It uses a specific Docker image
edwardelric233/ragflow:oc9.It exposes multiple ports, including HTTP and HTTPS.
It mounts several volumes for logs and Nginx configurations.
It sets environment variables from an
.envfile and inline environment variables.It configures GPU resource reservation for NVIDIA GPUs.
It includes special network and restart policies.
It sets extra host configuration to expose the host's internal IP, useful for Prometheus or related monitoring.
Important Note:
The RAGFlow team explicitly mentions this file is not actively maintained, so users should proceed with caution and are encouraged to contribute improvements via pull requests.
Detailed Explanation of Components
Included File
include:
- ./docker-compose-base.yml
Purpose:
This line includes the base Docker Compose configuration file,docker-compose-base.yml. This mechanism allows sharing common service definitions and settings, while this GPU-specific file overrides or extends those settings.Note:
Native Docker Compose does not supportincludedirective by default; this may depend on a custom preprocessor or tooling in the deployment pipeline.
Services
ragflow
The primary service defined in this file.
services:
ragflow:
depends_on:
mysql:
condition: service_healthy
image: edwardelric233/ragflow:oc9
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}
networks:
- ragflow
restart: on-failure
extra_hosts:
- "host.docker.internal:host-gateway"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
Explanation:
depends_on:
Waits for the
mysqlservice to become healthy before startingragflow.
image:
Uses the Docker image
edwardelric233/ragflow:oc9(likely a custom build optimized for OpenCore 9 with GPU support).
container_name:
Names the container
ragflow-serverfor easier identification.
ports:
Maps environment variable
SVR_HTTP_PORTto container port9380.Maps host ports
80and443to container ports80and443respectively for HTTP and HTTPS traffic.
volumes:
Mounts local directories and files into the container for logs and Nginx configuration.
This enables persistent logging and custom reverse proxy configurations.
env_file & environment:
Loads environment variables from a
.envfile.Sets additional environment variables including timezone (
TZ), Hugging Face API endpoint (HF_ENDPOINT), and a flagMACOS(likely a platform-specific toggle).
networks:
Connects the container to a Docker network named
ragflow(defined elsewhere, probably in the included base file).
restart:
Container is restarted on failure to improve resilience.
extra_hosts:
Adds an entry to resolve
host.docker.internalto the host gateway IP address.This is useful for scenarios where the container needs to communicate with services running on the host machine, e.g., Prometheus monitoring.
deploy.resources.reservations.devices:
Requests all available NVIDIA GPUs to be exposed to the container.
Requires Docker Engine with NVIDIA Container Toolkit installed.
Enables GPU acceleration inside the container.
Implementation Details
GPU Support:
The file leverages Docker's device reservation feature to allocate NVIDIA GPUs to the container, enabling hardware acceleration for AI workloads or other GPU-dependent processes running inside the RAGFlow server.Health Checks:
Thedepends_oncondition waits for themysqlservice to report healthy before starting theragflowservice, ensuring database availability.Port Mappings:
The service exposes multiple ports, including a custom port mapped via an environment variable, HTTP (80), and HTTPS (443), enabling external access to the RAGFlow server and possibly an embedded or proxied web service.Volume Mounts:
Logs and Nginx configuration files are mapped from the host to allow easier debugging, configuration changes, and log persistence without rebuilding the container.Extra Hosts:
Thehost.docker.internalalias is added for compatibility across platforms, particularly useful on Docker Desktop environments, which might be running on Windows or Mac OS.Restart Policy:
Usingon-failurerestart policy helps maintain service availability through automatic restarts after crashes.
Interaction with Other Parts of the System
mysql service:
Although not defined in this file, theragflowservice depends on amysqlservice which is expected to be healthy beforeragflowstarts. The MySQL database likely stores application data or metadata required by RAGFlow.docker-compose-base.yml:
This file is included at the top and presumably contains common or base service definitions, shared volumes, networks, or other service configurations.Nginx Config Files:
The volumes include Nginx configuration files mounted into the container, indicating that the container runs Nginx as a reverse proxy or web server, managing HTTP/HTTPS traffic routing..env File:
Environment variables are loaded from a.envfile, allowing external configuration of parameters such as timezone, endpoints, and platform flags without changing the Compose file.GPU Drivers and Docker Runtime:
Requires the NVIDIA Container Toolkit and compatible Docker runtime installed on the host to enable GPU passthrough.
Usage Example
To deploy the stack defined by this file:
# Ensure NVIDIA drivers and container toolkit are installed and configured
# Export required environment variables in .env file, e.g.:
# SVR_HTTP_PORT=8080
# TIMEZONE=Asia/Shanghai
# HF_ENDPOINT=https://huggingface.cn
# MACOS=false
# Run docker-compose with this file
docker-compose -f docker-compose-gpu-CN-oc9.yml up -d
This command will start the ragflow service with GPU support, linked to a healthy MySQL service, exposing the necessary ports and volumes.
Mermaid Diagram
This file defines a single main service that depends on a database service and includes volume mounts, environment variables, and GPU device reservations. The following flowchart illustrates the key structural relationships and resource dependencies:
flowchart TD
A[Start Ragflow Service] --> B{Is MySQL Healthy?}
B -- Yes --> C[Launch ragflow-container]
B -- No --> D[Wait for MySQL]
C --> E[Mount Volumes]
C --> F[Set Environment Variables]
C --> G[Expose Ports: ${SVR_HTTP_PORT}, 80, 443]
C --> H[Connect to ragflow network]
C --> I[Reserve GPUs: NVIDIA (all)]
E --> J[./ragflow-logs:/ragflow/logs]
E --> K[./nginx/*.conf:/etc/nginx/*.conf]
I --> L[NVIDIA Container Toolkit Required]
D --> B
style C fill:#9fdfbf,stroke:#333,stroke-width:2px
style B fill:#f9f,stroke:#333,stroke-width:2px
Summary
This YAML file configures a GPU-enabled deployment of the RAGFlow server.
It depends on a healthy MySQL service.
It uses specific Docker image tagged
oc9for RAGFlow.Ports 80, 443, and a custom port mapped via environment variable are exposed.
It mounts local log and Nginx configuration files for persistence and customization.
It passes environment variables from file and inline.
It reschedules the container on failure.
GPU resources are reserved for the container using NVIDIA drivers.
It adds host IP resolution for internal network access.
The file is not actively maintained; users should verify compatibility with their environment.
This configuration is intended for advanced users with GPU-enabled Docker environments and familiarity with Docker Compose service orchestration, particularly in Chinese network environments or setups requiring specific endpoint configurations.