From 0bcebac21c12b1ca0e2304a9d8e21ce3e01a8cd6 Mon Sep 17 00:00:00 2001 From: Will Wilson Date: Sun, 8 Mar 2026 21:41:15 +0000 Subject: [PATCH] fix: use TCP socket health checks for database services Add bash /dev/tcp health checks to MongoDB (port 27017) and PostgreSQL/ pgvector (port 5432) services, which previously had no health checks. Update depends_on conditions so dependent services (rag_api, api) wait for their database dependencies to be healthy before starting. Files changed: docker-compose.yml, deploy-compose.yml, rag.yml Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- deploy-compose.yml | 21 ++++++++++++++++++--- docker-compose.yml | 21 ++++++++++++++++++--- rag.yml | 9 ++++++++- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/deploy-compose.yml b/deploy-compose.yml index 968768b818..51844f9776 100644 --- a/deploy-compose.yml +++ b/deploy-compose.yml @@ -9,8 +9,10 @@ services: ports: - 3080:3080 depends_on: - - mongodb - - rag_api + mongodb: + condition: service_healthy + rag_api: + condition: service_started restart: always extra_hosts: - "host.docker.internal:host-gateway" @@ -51,6 +53,12 @@ services: volumes: - ./data-node:/data/db command: mongod --noauth + healthcheck: + test: ["CMD", "bash", "-c", "echo > /dev/tcp/localhost/27017"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s meilisearch: container_name: chat-meilisearch image: getmeili/meilisearch:v1.35.1 @@ -73,6 +81,12 @@ services: restart: always volumes: - pgdata2:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "bash", "-c", "echo > /dev/tcp/localhost/5432"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s rag_api: image: registry.librechat.ai/danny-avila/librechat-rag-api-dev-lite:latest environment: @@ -80,7 +94,8 @@ services: - RAG_PORT=${RAG_PORT:-8000} restart: always depends_on: - - vectordb + vectordb: + condition: service_healthy env_file: - .env diff --git a/docker-compose.yml b/docker-compose.yml index 079cdb74b6..3f32d468b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,8 +7,10 @@ services: ports: - "${PORT}:${PORT}" depends_on: - - mongodb - - rag_api + mongodb: + condition: service_healthy + rag_api: + condition: service_started image: registry.librechat.ai/danny-avila/librechat-dev:latest restart: always user: "${UID}:${GID}" @@ -35,6 +37,12 @@ services: volumes: - ./data-node:/data/db command: mongod --noauth + healthcheck: + test: ["CMD", "bash", "-c", "echo > /dev/tcp/localhost/27017"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s meilisearch: container_name: chat-meilisearch image: getmeili/meilisearch:v1.35.1 @@ -56,6 +64,12 @@ services: restart: always volumes: - pgdata2:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "bash", "-c", "echo > /dev/tcp/localhost/5432"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s rag_api: container_name: rag_api image: registry.librechat.ai/danny-avila/librechat-rag-api-dev-lite:latest @@ -64,7 +78,8 @@ services: - RAG_PORT=${RAG_PORT:-8000} restart: always depends_on: - - vectordb + vectordb: + condition: service_healthy env_file: - .env diff --git a/rag.yml b/rag.yml index 9684d76cf5..ff4b43d52f 100644 --- a/rag.yml +++ b/rag.yml @@ -11,6 +11,12 @@ services: - pgdata2:/var/lib/postgresql/data ports: - "5433:5432" + healthcheck: + test: ["CMD", "bash", "-c", "echo > /dev/tcp/localhost/5432"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s rag_api: image: registry.librechat.ai/danny-avila/librechat-rag-api-dev:latest @@ -23,7 +29,8 @@ services: ports: - "${RAG_PORT}:${RAG_PORT}" depends_on: - - vectordb + vectordb: + condition: service_healthy env_file: - .env