-
Notifications
You must be signed in to change notification settings - Fork 136
feat(deployment): Basic docker-compose file #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds a docker-compose service for running Sourcebot with persistent volume, host-mounted config, ports, environment variables, and restart policy. Updates the deployment guide to use Docker Compose instead of docker run, including steps to fetch the compose file and launch the service, plus links to configuration docs. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant DC as Docker Compose
participant C as Sourcebot Container
participant V as Named Volume (sourcebot_data)
participant CFG as Host Config (./config.json)
Dev->>DC: docker compose up -d
DC->>C: Create & start container (image: ghcr.io/.../sourcebot:latest)
Note over C: Env vars injected<br/>Port 3000 exposed
DC-->>V: Attach /data volume
DC-->>C: Bind ./config.json -> /data/config.json
C->>CFG: Read configuration
C->>V: Persist runtime data under /data
C-->>Dev: Service listening on http://localhost:3000
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
@brendan-kellam your pull request is missing a changelog! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (9)
docker-compose.yml (5)
3-4
: Avoid the “latest” tag; pin to a version or digestlatest makes builds non-reproducible and can break users unexpectedly. Pin to a semver tag (e.g., 0.15.2) or a digest; keep pull_policy if you want freshness.
- image: ghcr.io/sourcebot-dev/sourcebot:latest + image: ghcr.io/sourcebot-dev/sourcebot:0.15.2Alternatively:
- image: ghcr.io/sourcebot-dev/sourcebot:latest + image: ghcr.io/sourcebot-dev/sourcebot@sha256:<digest>
11-57
: Use env_file to keep secrets out of the compose and simplify overridesListing dozens of envs inline encourages committing secrets. Compose supports env_file: .env, which plays well with your defaults. Recommend adding env_file and trimming the inline list to only required keys with sane defaults.
sourcebot: + env_file: + - .envDocs should include a sample .env and .gitignore guidance. I can add that if you want.
48-49
: If GOOGLE_APPLICATION_CREDENTIALS is set, mount the credentials fileUsers setting GOOGLE_APPLICATION_CREDENTIALS will need to bind-mount the referenced path. Provide a commented example to prevent 404 path errors.
volumes: - sourcebot_data:/data - ./config.json:/config/config.json + # Example: mount GCP service account JSON if using Vertex/GenAI + # - ./gcp-sa.json:/gcp/sa.jsonAnd in env:
- - GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS:-} + - GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS:-/gcp/sa.json}Also applies to: 8-10
5-5
: container_name can hinder scaling and “docker compose up --scale”Not a blocker here, but consider dropping container_name for more flexibility in multi-replica or side-by-side runs.
58-58
: Optional: add a basic healthcheck for better UX and orchestrationA healthcheck enables “healthy” status and plays nicely with depends_on conditions. If your app exposes one, wire it in.
sourcebot: @@ restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "curl -fsS http://localhost:3000/health || exit 1"] + interval: 10s + timeout: 3s + retries: 10If the health endpoint differs, please replace accordingly.
docs/docs/deployment-guide.mdx (4)
7-7
: Capitalize “Docker Compose” consistentlyMinor copy tweak for brand consistency.
-The following guide will walk you through the steps to deploy Sourcebot locally using [Docker compose](https://docs.docker.com/compose). +The following guide will walk you through the steps to deploy Sourcebot locally using [Docker Compose](https://docs.docker.com/compose).
20-24
: Pin the curl URL to a released tag/commit for reproducibilityPulling docker-compose.yml from main can drift and break the walkthrough. Suggest pinning to a release tag (or commit SHA) and optionally mentioning how to grab “latest.”
-Download the [docker-compose.yml](https://github.com/sourcebot-dev/sourcebot/blob/main/docker-compose.yml) file from the Sourcebot repository. +Download the [docker-compose.yml](https://github.com/sourcebot-dev/sourcebot/blob/v0.15.2/docker-compose.yml) file from the Sourcebot repository. @@ -curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/docker-compose.yml +curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/v0.15.2/docker-compose.yml +# Or, to fetch the latest from main (may change without notice): +# curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/docker-compose.yml
35-36
: Confirm JSON-with-comments support or remove the inline commentThe sample uses // comments inside JSON. If config.json is strict JSON, this will break copying/pasting. If JSONC is supported, add a brief note and link to the parser support; otherwise, remove the comment from the sample.
- // comments are supported + // Comments are supported in config.json (JSONC). See the docs for details.Or drop the line entirely if not supported.
Also applies to: 45-46
17-19
: Add a .env step to manage secrets cleanlySince the compose relies heavily on environment variables, add a step to create a .env file and reference security hygiene (.gitignore).
<Step title="Requirements"> - - docker & docker compose -> 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. + - a text editor to create config.json and a .env file (don’t commit .env) </Step> + <Step title="Create a .env file (recommended)"> + Create a `.env` file with your environment variables (database, redis, auth, provider keys). The compose will auto-load it. + + ```bash wrap icon="terminal" + cat > .env << 'EOF' + AUTH_URL=http://localhost:3000 + DATABASE_URL=postgresql://postgres:postgres@postgres:5432/sourcebot + REDIS_URL=redis://redis:6379 + # OPENAI_API_KEY=... + EOF + ``` + </Step>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
docker-compose.yml
(1 hunks)docs/docs/deployment-guide.mdx
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*
📄 CodeRabbit inference engine (.cursor/rules/style.mdc)
Filenames should always be camelCase. Exception: if there are filenames in the same directory with a format other than camelCase, use that format to keep things consistent.
Files:
docker-compose.yml
docs/docs/deployment-guide.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (2)
docker-compose.yml (1)
60-62
: LGTM on volume declarationNamed volume for app data is appropriate for local persistence.
docs/docs/deployment-guide.mdx (1)
67-67
: Nice cross-link to env var docsGood addition for discoverability.
volumes: | ||
- ./config.json:/data/config.json | ||
- sourcebot_data:/data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
- DATABASE_URL=${DATABASE_URL:-postgresql://postgres@localhost:5432/sourcebot} | ||
- REDIS_URL=${REDIS_URL:-redis://localhost:6379} | ||
- AUTH_URL=${AUTH_URL:-http://localhost:3000} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
- 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.
<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 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Adds a basic docker-compose file to simplify the local deployment story of Sourcebot. Also updates the deployment docs to use the docker-compose file.
Summary by CodeRabbit
New Features
Documentation