Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
services:
sourcebot:
image: ghcr.io/sourcebot-dev/sourcebot:latest
pull_policy: always
container_name: sourcebot
ports:
- "3000:3000"
volumes:
- ./config.json:/data/config.json
- sourcebot_data:/data
Comment on lines +8 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix overlapping mounts: config bind is shadowed by the /data volume

You’re bind-mounting a file inside a directory that’s also mounted as a named volume. The /data volume will mask the file bind to /data/config.json at runtime, so CONFIG_PATH will not resolve to the host’s config.json.

Refactor to mount the config at a separate path and update CONFIG_PATH accordingly.

 services:
   sourcebot:
@@
-    volumes:
-      - ./config.json:/data/config.json
-      - sourcebot_data:/data
+    volumes:
+      - sourcebot_data:/data
+      - ./config.json:/config/config.json
@@
-      - CONFIG_PATH=/data/config.json
+      - CONFIG_PATH=/config/config.json

Also applies to: 12-12

🤖 Prompt for AI Agents
In docker-compose.yml around lines 8-10 (and also line 12), the bind-mount of
./config.json to /data/config.json is being shadowed by the named volume mounted
at /data; move the host config bind to a separate non-overlapping path (for
example /config/config.json or /app/config.json) and update the service's
CONFIG_PATH environment variable to point to that new path, leaving the named
volume mounted at /data unchanged so the file bind is not masked at runtime.

environment:
- CONFIG_PATH=/data/config.json
- DATABASE_URL=${DATABASE_URL:-postgresql://postgres@localhost:5432/sourcebot}
- REDIS_URL=${REDIS_URL:-redis://localhost:6379}
- AUTH_URL=${AUTH_URL:-http://localhost:3000}
Comment on lines +13 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Default DATABASE_URL/REDIS_URL point to “localhost” inside the container; app won’t boot without external services

As written, the service will try to reach Postgres and Redis on 127.0.0.1 inside the container, where nothing is listening. For a “basic local deployment,” users will hit connection failures unless they override envs to managed services or you provision DB/cache within the same compose file.

Two workable options (pick one):

  • Provide Postgres and Redis services in this compose and point URLs to service DNS names.
  • Keep a single-service compose, but default DATABASE_URL/REDIS_URL to host.docker.internal for Mac/Windows and call this out in docs, with a Linux note.

I recommend bundling Postgres/Redis for a turnkey local flow. Example patch:

 services:
   sourcebot:
@@
-      - DATABASE_URL=${DATABASE_URL:-postgresql://postgres@localhost:5432/sourcebot}
-      - REDIS_URL=${REDIS_URL:-redis://localhost:6379}
+      - DATABASE_URL=${DATABASE_URL:-postgresql://postgres:postgres@postgres:5432/sourcebot}
+      - REDIS_URL=${REDIS_URL:-redis://redis:6379}
+    depends_on:
+      postgres:
+        condition: service_healthy
+      redis:
+        condition: service_healthy
@@
+  postgres:
+    image: postgres:16-alpine
+    environment:
+      - POSTGRES_DB=sourcebot
+      - POSTGRES_USER=postgres
+      - POSTGRES_PASSWORD=postgres
+    volumes:
+      - sourcebot_pg:/var/lib/postgresql/data
+    healthcheck:
+      test: ["CMD-SHELL", "pg_isready -U postgres -d sourcebot"]
+      interval: 5s
+      timeout: 3s
+      retries: 30
+
+  redis:
+    image: redis:7-alpine
+    command: ["redis-server", "--appendonly", "yes"]
+    healthcheck:
+      test: ["CMD", "redis-cli", "ping"]
+      interval: 5s
+      timeout: 3s
+      retries: 30
@@
 volumes:
   sourcebot_data:
     driver: local
+  sourcebot_pg:

If you prefer keeping the single-service compose, consider:

-      - DATABASE_URL=${DATABASE_URL:-postgresql://postgres@localhost:5432/sourcebot}
-      - REDIS_URL=${REDIS_URL:-redis://localhost:6379}
+      - DATABASE_URL=${DATABASE_URL:-postgresql://postgres@host.docker.internal:5432/sourcebot}
+      - REDIS_URL=${REDIS_URL:-redis://host.docker.internal:6379}

…and document Linux alternatives. I can open a follow-up PR with either approach.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- DATABASE_URL=${DATABASE_URL:-postgresql://postgres@localhost:5432/sourcebot}
- REDIS_URL=${REDIS_URL:-redis://localhost:6379}
- AUTH_URL=${AUTH_URL:-http://localhost:3000}
services:
sourcebot:
environment:
- DATABASE_URL=${DATABASE_URL:-postgresql://postgres:postgres@postgres:5432/sourcebot}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
- AUTH_URL=${AUTH_URL:-http://localhost:3000}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
postgres:
image: postgres:16-alpine
environment:
- POSTGRES_DB=sourcebot
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- sourcebot_pg:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d sourcebot"]
interval: 5s
timeout: 3s
retries: 30
redis:
image: redis:7-alpine
command: ["redis-server", "--appendonly", "yes"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 30
volumes:
sourcebot_data:
driver: local
sourcebot_pg:
🤖 Prompt for AI Agents
In docker-compose.yml around lines 13-15, the DATABASE_URL/REDIS_URL default to
localhost which points inside the container and breaks startup; instead add
Postgres and Redis services to this compose and change the defaults to use the
service hostnames (e.g. DATABASE_URL to
postgresql://postgres@postgres:5432/sourcebot and REDIS_URL to
redis://redis:6379), and ensure the new services have basic configuration
(image, volumes for persistence, environment for Postgres user/db, and ports as
needed) so the app can connect to them by service DNS; alternatively, if you
prefer a single-service compose, change the defaults to use host.docker.internal
and document Linux caveats, but the preferred fix is bundling Postgres and Redis
and pointing the env defaults to those service names.

- AUTH_SECRET=${AUTH_SECRET:-}
- AUTH_CREDENTIALS_LOGIN_ENABLED=${AUTH_CREDENTIALS_LOGIN_ENABLED:-true}
- AUTH_EMAIL_CODE_LOGIN_ENABLED=${AUTH_EMAIL_CODE_LOGIN_ENABLED:-false}
- SMTP_CONNECTION_URL=${SMTP_CONNECTION_URL:-}
- EMAIL_FROM_ADDRESS=${EMAIL_FROM_ADDRESS:-}
- SOURCEBOT_EE_LICENSE_KEY=${SOURCEBOT_EE_LICENSE_KEY:-}
- SOURCEBOT_ENCRYPTION_KEY=${SOURCEBOT_ENCRYPTION_KEY:-}
- SOURCEBOT_TELEMETRY_DISABLED=${SOURCEBOT_TELEMETRY_DISABLED:-false}
- ZOEKT_WEBSERVER_URL=${ZOEKT_WEBSERVER_URL:-http://localhost:6070}
- SHARD_MAX_MATCH_COUNT=${SHARD_MAX_MATCH_COUNT:-}
- TOTAL_MAX_MATCH_COUNT=${TOTAL_MAX_MATCH_COUNT:-}
- ZOEKT_MAX_WALL_TIME_MS=${ZOEKT_MAX_WALL_TIME_MS:-}

# AWS
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:-}
- AWS_REGION=${AWS_REGION:-}
# OpenAI
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
# Anthropic
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
# Azure
- AZURE_API_KEY=${AZURE_API_KEY:-}
- AZURE_RESOURCE_NAME=${AZURE_RESOURCE_NAME:-}
# DeepSeek
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-}
# Google gen ai
- GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY:-}
# Google vertex
- GOOGLE_VERTEX_PROJECT=${GOOGLE_VERTEX_PROJECT:-}
- GOOGLE_VERTEX_REGION=${GOOGLE_VERTEX_REGION:-}
- GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS:-}
- GOOGLE_VERTEX_THINKING_BUDGET_TOKENS=${GOOGLE_VERTEX_THINKING_BUDGET_TOKENS:-}
- GOOGLE_VERTEX_INCLUDE_THOUGHTS=${GOOGLE_VERTEX_INCLUDE_THOUGHTS:-}
# XAI
- XAI_API_KEY=${XAI_API_KEY:-}
# Mistral
- MISTRAL_API_KEY=${MISTRAL_API_KEY:-}
# Openrouter
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}

restart: unless-stopped

volumes:
sourcebot_data:
driver: local
44 changes: 19 additions & 25 deletions docs/docs/deployment-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ title: "Deployment guide"

import SupportedPlatforms from '/snippets/platform-support.mdx'

The following guide will walk you through the steps to deploy Sourcebot on your own infrastructure. Sourcebot is distributed as a [single docker container](/docs/overview#architecture) that can be deployed to a k8s cluster, a VM, or any platform that supports docker.
Sourcebot is distributed as a [single docker container](/docs/overview#architecture) that can be deployed to a k8s cluster, a VM, or any platform that supports docker. The following guide will walk you through the steps to deploy Sourcebot locally using [Docker compose](https://docs.docker.com/compose).


<Note>Hit an issue? Please let us know on [GitHub](https://github.com/sourcebot-dev/sourcebot/issues/new/choose) or by [emailing us](mailto:team@sourcebot.dev).</Note>
<Note>Hit an issue? Please let us know on [GitHub](https://github.com/sourcebot-dev/sourcebot/issues/new) or by [emailing us](mailto:team@sourcebot.dev).</Note>

## Walkthrough
---

<Steps>
<Step title="Requirements">
- Docker -> use [Docker Desktop](https://www.docker.com/products/docker-desktop/) on Mac or Windows.
- docker & docker compose -> use [Docker Desktop](https://www.docker.com/products/docker-desktop/) on Mac or Windows.
</Step>
<Step title="Obtain the Docker Compose file">
Download the [docker-compose.yml](https://github.com/sourcebot-dev/sourcebot/blob/main/docker-compose.yml) file from the Sourcebot repository.

```bash wrap icon="terminal"
curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/docker-compose.yml
```
</Step>
<Step title="Create a config.json">
Create a `config.json` file that tells Sourcebot which repositories to sync and index:
Expand All @@ -38,40 +48,24 @@ The following guide will walk you through the steps to deploy Sourcebot on your
<Step title="Launch your instance">
<Warning>If you're deploying Sourcebot behind a domain, you must set the [AUTH_URL](/docs/configuration/environment-variables) environment variable.</Warning>

Launch your Sourcebot instance:

In the same directory as `config.json`, run the following command to start your instance:

``` bash icon="terminal" Start the Sourcebot container
docker run \
-p 3000:3000 \
--pull=always \
--rm \
-v $(pwd):/data \
-e CONFIG_PATH=/data/config.json \
--name sourcebot \
ghcr.io/sourcebot-dev/sourcebot:latest
```bash wrap icon="terminal"
docker compose up -d
```
Comment on lines 48 to 55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Launching will fail without Postgres/Redis; add guidance or include them in compose

Given the compose currently runs only Sourcebot, the defaults point to localhost inside the container and the app will fail to connect. Either:

  • Add Postgres/Redis services to docker-compose.yml (preferred), or
  • Instruct users to set DATABASE_URL/REDIS_URL to reachable endpoints (e.g., host.docker.internal for Mac/Windows) before running docker compose up -d, with a Linux note.

Suggest adding one of the following snippets here for a turnkey experience.

Option A (recommended): direct users to a compose file that includes Postgres/Redis.

curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/v0.15.2/examples/docker-compose.with-db.yml
docker compose up -d

Option B: configure external services via .env.

cat > .env << 'EOF'
DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/sourcebot
REDIS_URL=redis://host.docker.internal:6379
AUTH_URL=http://localhost:3000
EOF

docker compose up -d

I can contribute the examples/docker-compose.with-db.yml variant if helpful.

🤖 Prompt for AI Agents
In docs/docs/deployment-guide.mdx around lines 48-55, the guide currently only
runs Sourcebot and will fail because Postgres/Redis are not available inside the
container; update this section to either (A) point readers to a docker-compose
that includes Postgres and Redis (preferred) by showing the curl command to
fetch examples/docker-compose.with-db.yml and then docker compose up -d, or (B)
provide an alternative .env snippet and instructions to set DATABASE_URL and
REDIS_URL to reachable endpoints (e.g., host.docker.internal on Mac/Windows,
note Linux differences) before running docker compose up -d; include both
options concisely so users can choose turnkey compose or external service
configuration.


<Accordion title="Details">
**This command**:
- pulls the latest version of the `sourcebot` docker image.
- mounts the working directory to `/data` in the container to allow Sourcebot to persist data across restarts, and to access the `config.json`. In your local directory, you should see a `.sourcebot` folder created that contains all persistent data.
- runs any pending database migrations.
- starts up all services, including the webserver exposed on port 3000.
- reads `config.json` and starts syncing.
</Accordion>

</Step>

<Step title="Complete onboarding">
Navigate to `http://localhost:3000` and complete the onboarding flow.
Navigate to [http://localhost:3000](http://localhost:3000) and complete the onboarding flow.
</Step>

<Step title="Done">
You're all set! If you'd like to setup [Ask Sourcebot](/docs/features/ask/overview), configure a language model [provider](/docs/configuration/language-model-providers).
</Step>
</Steps>

Checkout the [configuration docs](/docs/configuration/environment-variables) to learn more about how to configure your deployment.

## Next steps
---

Expand Down