docker-compose-CN-oc9.yml
Overview
The docker-compose-CN-oc9.yml file is a Docker Compose configuration designed to orchestrate containerized services for the RAGFlow application, specifically tailored for a certain deployment environment (likely China, as suggested by the CN in the filename) and version oc9. It extends a base Docker Compose configuration (docker-compose-base.yml) by including it and then adds a customized service definition for the ragflow server.
This file is not actively maintained by the RAGFlow team and is provided as-is, with a note encouraging users to submit pull requests for improvements if needed.
The primary functionality includes:
Defining the
ragflowservice container with its dependencies, environment variables, ports, volumes, and networking.Ensuring the
ragflowservice starts only after themysqlservice is healthy.Configuring extra host settings for internal networking, helpful for Prometheus monitoring setups.
Mounting custom NGINX configuration files and logs for the
ragflowservice.Loading environment variables from a
.envfile.
Detailed Explanation
Included File
include:
- ./docker-compose-base.yml
Purpose: The file imports the base Docker Compose configuration from
docker-compose-base.yml. This allows it to extend or override base configurations.Usage: This method is a YAML extension not natively supported by Docker Compose, so it assumes usage of an extended tool or manual pre-processing.
Services
ragflow Service
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"
Parameters and Configuration
depends_on:
Waits for the
mysqlservice to become healthy before startingragflow. This ensures database availability.condition: service_healthyis used to extend the basic dependency by adding health check awareness.
image:
Uses the Docker image
edwardelric233/ragflow:oc9.This is a pre-built image tagged for version
oc9.
container_name:
Names the container
ragflow-serverfor easier identification.
ports:
Maps host ports to container ports:
${SVR_HTTP_PORT}:9380— maps a customizable server HTTP port to container port 9380.80:80and443:443— standard HTTP and HTTPS ports forwarded to the container.
volumes:
Mounts local directories and files into the container:
./ragflow-logs:/ragflow/logs— persistent log storage.Several NGINX config files under
/etc/nginx/for custom reverse proxy and server configurations.
env_file:
Loads environment variables from a
.envfile in the same directory, allowing sensitive or environment-specific configuration to be separated.
environment:
Sets container environment variables by referencing variables from the host environment or
.envfile:TZ— timezone setting.HF_ENDPOINT— likely an endpoint URL, possibly for Hugging Face or other API.MACOS— a boolean or flag indicating if MacOS-specific behavior is needed.
networks:
Connects the service to the
ragflowDocker network, facilitating inter-container communication.
restart:
Configured to restart the container automatically on failure to improve resilience.
extra_hosts:
Adds an entry to the container’s
/etc/hostsfile mappinghost.docker.internalto the host gateway IP.This is useful for services inside the container to communicate with host services (such as Prometheus monitoring).
Usage Example
To deploy the ragflow service using this compose file, assuming Docker Compose is installed and the environment variables are set, run:
docker-compose -f docker-compose-CN-oc9.yml up -d
This command will:
Include base services from
docker-compose-base.yml.Start
mysqland wait until it is healthy.Start the
ragflowcontainer with all specified configurations.Set up networking, mounts, and environment variables as defined.
Important Implementation Details
Health-Check Dependency: The
depends_onwithcondition: service_healthyrequires that themysqlservice has a health check defined in the base compose file. This ensures proper orchestration and avoids startup race conditions.Custom NGINX Configuration: The mounted config files suggest that NGINX is used as a reverse proxy inside the container, possibly to route traffic or provide SSL termination.
Port Mapping: The use of
${SVR_HTTP_PORT}environment variable enables flexible port configuration for different deployment environments.Extra Hosts for Prometheus: The comment about Prometheus and
host.docker.internalindicates that monitoring tools outside the container may be integrated, requiring special Docker networking configurations.
Interaction with Other Parts of the System
docker-compose-base.yml: This file is the foundation and likely defines core services such asmysqland networking. This file extends or overrides it.MySQL Service:
ragflowdepends onmysql, which must expose health checks. The database is critical forragflowoperation.NGINX Configuration Files: Local
./nginx/directory contains configuration files that are injected into the container, allowing customization of HTTP reverse proxy behavior.Environment Variables and
.env: This file depends on an external.envfile for sensitive or environment-specific settings, ensuring separation of code and configuration.Docker Network
ragflow: Both this service and possibly others defined in the base file communicate over this network.
Mermaid Diagram
The following flowchart illustrates the relationships and main components defined or referenced in docker-compose-CN-oc9.yml:
flowchart TD
A[docker-compose-CN-oc9.yml] -->|includes| B[docker-compose-base.yml]
B --> C[mysql service]
A --> D[ragflow service]
D -->|depends_on healthy| C
D --> E[Mount ./ragflow-logs to /ragflow/logs]
D --> F[Mount ./nginx/*.conf to /etc/nginx/]
D --> G[Uses image edwardelric233/ragflow:oc9]
D --> H[Ports: ${SVR_HTTP_PORT}:9380, 80:80, 443:443]
D --> I[Environment vars from .env + TZ, HF_ENDPOINT, MACOS]
D --> J[Network: ragflow]
D --> K[Restart policy: on-failure]
D --> L[Extra hosts: host.docker.internal -> host-gateway]
Summary
Purpose: Define the
ragflowservice container with dependencies, environment, ports, volumes, and networking for deployment in a specific environment (likely China, version oc9).Key Features: Health-check dependency on MySQL, custom NGINX configuration, environment variable support, and Docker network integration.
Usage Context: Extends a base compose file, requires
.envfile, and is not actively maintained by the original RAGFlow team.Extensibility: Users are encouraged to contribute improvements via pull requests.
Monitoring Support: Special configuration for Prometheus monitoring connectivity.
This file serves as a focused deployment descriptor for the RAGFlow server, making container orchestration predictable and environment-specific.