From 5e7be735b485a55ed5b8564a81a3fd8f03c189f5 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:04:22 +0000 Subject: [PATCH] self-hosted/external-services/redis: Add Docker Compose, drop single-container Document REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT, the services that need them on Docker Compose, and the deploy-sourcegraph-docker external-redis example. Remove the deprecated single-container section. Amp-Thread-ID: https://ampcode.com/threads/T-5e703d95-d3ee-4486-9b11-630a3ae8b3e2 Co-authored-by: Amp --- cspell-allow-list.txt | 1 + docs/self-hosted/external-services/redis.mdx | 32 +++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cspell-allow-list.txt b/cspell-allow-list.txt index 295f4911e..4ade45921 100644 --- a/cspell-allow-list.txt +++ b/cspell-allow-list.txt @@ -439,6 +439,7 @@ rbacs readwrite reclone recloning +rediss reexecuting referer refreshable diff --git a/docs/self-hosted/external-services/redis.mdx b/docs/self-hosted/external-services/redis.mdx index bd7a47933..bb6513d47 100644 --- a/docs/self-hosted/external-services/redis.mdx +++ b/docs/self-hosted/external-services/redis.mdx @@ -2,22 +2,32 @@ **Version requirements**: We support any version _starting from 6.2_. Redis Cluster and Redis Sentinel are not supported. -Generally, there is no reason to do this as Sourcegraph only stores ephemeral cache and session data in Redis. However, if you want to use an external Redis server with Sourcegraph, you can follow the deployment specific guidance below: +Generally, there is no reason to do this as Sourcegraph only stores ephemeral cache and session data in Redis. However, if you want to use an external Redis server with Sourcegraph, you can follow the deployment specific guidance below. -## Single-container +Sourcegraph uses two Redis instances, configured with these environment variables: -Add the `REDIS_ENDPOINT` environment variable to your `docker run` command and Sourcegraph will use that Redis server instead of its built-in one. The string must either have the format `$HOST:PORT` -or follow the [IANA specification for Redis URLs](https://www.iana.org/assignments/uri-schemes/prov/redis) (e.g., `redis://:mypassword@host:6379/2`). For example: +- `REDIS_CACHE_ENDPOINT` for cached data. Set `maxmemory-policy allkeys-lru` on this instance; the frontend logs a warning on startup if it is not set. +- `REDIS_STORE_ENDPOINT` for persistent data, such as user sessions and locks. Set `maxmemory-policy noeviction` on this instance. -``` -docker run [...] - -e REDIS_ENDPOINT=redis.example.com:6379 -sourcegraph/server:{CURRENT_VERSION} -``` +Each value is either `host:port`, or a URL following the [IANA specification for Redis URLs](https://www.iana.org/assignments/uri-schemes/prov/redis), such as `redis://:mypassword@redis-store.example.com:6379/0`. Use the `rediss://` scheme for a TLS connection. -> NOTE: On Mac/Windows, if trying to connect to a Redis server on the same host machine, remember that Sourcegraph is running inside a Docker container inside of the Docker virtual machine. You may need to specify your actual machine IP address and not `localhost` or `127.0.0.1` as that refers to the Docker VM itself. +## Docker Compose -If using Docker for Desktop, `host.docker.internal` will resolve to the host IP address. +Set both environment variables on every service that connects to Redis: + +- `sourcegraph-frontend-0` +- `sourcegraph-frontend-internal` +- `gitserver-0` +- `searcher-0` +- `worker` +- `precise-code-intel-worker` +- `syntactic-code-intel-worker` + +A service without them keeps connecting to the built-in `redis-cache` and `redis-store` containers. + +1. Copy the [external Redis example](https://github.com/sourcegraph/deploy-sourcegraph-docker/blob/main/docker-compose/examples/external-redis/docker-compose.override.yaml) into your `docker-compose.override.yaml`. It sets the variables on these services and disables the built-in Redis containers. +2. Replace the example values of `REDIS_CACHE_ENDPOINT` and `REDIS_STORE_ENDPOINT` with your Redis endpoints. +3. Apply the change with `docker compose up -d --remove-orphans`. ## Kubernetes