Skip to content

Commit 825cef9

Browse files
feat(deployment): Basic docker-compose file (#480)
1 parent dd5cf61 commit 825cef9

File tree

13 files changed

+160
-120
lines changed

13 files changed

+160
-120
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ RUN mkdir -p /run/postgresql && \
240240

241241
# Make app directory accessible to both root and sourcebot user
242242
RUN chown -R sourcebot:sourcebot /app
243+
# Make data directory accessible to both root and sourcebot user
244+
RUN chown -R sourcebot:sourcebot /data
243245

244246
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
245247
COPY prefix-output.sh ./prefix-output.sh

README.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,22 @@ https://github.com/user-attachments/assets/31ec0669-707d-4e03-b511-1bc33d44197a
7272

7373
# Deploy Sourcebot
7474

75-
Sourcebot can be deployed in seconds using our official docker image. Visit our [docs](https://docs.sourcebot.dev/docs/deployment-guide) for more information.
75+
Sourcebot can be deployed in seconds using Docker Compose. Visit our [docs](https://docs.sourcebot.dev/docs/deployment/docker-compose) for more information.
7676

77-
1. Create a config
77+
1. Download the docker-compose.yml file
78+
```sh
79+
curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/docker-compose.yml
80+
```
81+
82+
2. In the same directory as the `docker-compose.yml` file, create a [configuration file](https://docs.sourcebot.dev/docs/configuration/config-file). The configuration file is a JSON file that configures Sourcebot's behaviour, including what repositories to index, language model providers, auth providers, and more.
7883
```sh
7984
touch config.json
8085
echo '{
8186
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
87+
// Comments are supported.
88+
// This config creates a single connection to GitHub.com that
89+
// indexes the Sourcebot repository
8290
"connections": {
83-
// Comments are supported
8491
"starter-connection": {
8592
"type": "github",
8693
"repos": [
@@ -91,30 +98,12 @@ echo '{
9198
}' > config.json
9299
```
93100

94-
2. Run the docker container
101+
3. Update the secrets in the `docker-compose.yml` and then run Sourcebot using:
95102
```sh
96-
docker run \
97-
-p 3000:3000 \
98-
--pull=always \
99-
--rm \
100-
-v $(pwd):/data \
101-
-e CONFIG_PATH=/data/config.json \
102-
--name sourcebot \
103-
ghcr.io/sourcebot-dev/sourcebot:latest
103+
docker compose up
104104
```
105-
<details>
106-
<summary>What does this command do?</summary>
107-
108-
- Pull and run the Sourcebot docker image from [ghcr.io/sourcebot-dev/sourcebot:latest](https://github.com/sourcebot-dev/sourcebot/pkgs/container/sourcebot).
109-
- Mount the current directory (`-v $(pwd):/data`) to allow Sourcebot to persist the `.sourcebot` cache.
110-
- Clones sourcebot at `HEAD` into `.sourcebot/github/sourcebot-dev/sourcebot`.
111-
- Indexes sourcebot into a .zoekt index file in `.sourcebot/index/`.
112-
- Map port 3000 between your machine and the docker image.
113-
- Starts the web server on port 3000.
114-
</details>
115-
</br>
116105

117-
3. Visit `http://localhost:3000` to start using Sourcebot
106+
4. Visit `http://localhost:3000` to start using Sourcebot
118107
</br>
119108

120109
To configure Sourcebot (index your own repos, connect your LLMs, etc), check out our [docs](https://docs.sourcebot.dev/docs/configuration/config-file).

docker-compose.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
services:
2+
sourcebot:
3+
image: ghcr.io/sourcebot-dev/sourcebot:latest
4+
user: sourcebot
5+
restart: always
6+
container_name: sourcebot
7+
depends_on:
8+
postgres:
9+
condition: service_healthy
10+
redis:
11+
condition: service_healthy
12+
ports:
13+
- "3000:3000"
14+
volumes:
15+
- ./config.json:/data/config.json
16+
- sourcebot_data:/data
17+
environment:
18+
- CONFIG_PATH=/data/config.json
19+
- AUTH_URL=${AUTH_URL:-http://localhost:3000}
20+
- AUTH_SECRET=${AUTH_SECRET:-000000000000000000000000000000000} # CHANGEME: generate via `openssl rand -base64 33`
21+
- SOURCEBOT_ENCRYPTION_KEY=${SOURCEBOT_ENCRYPTION_KEY:-000000000000000000000000000000000} # CHANGEME: generate via `openssl rand -base64 24`
22+
- DATABASE_URL=${DATABASE_URL:-postgresql://postgres:postgres@postgres:5432/postgres} # CHANGEME
23+
- REDIS_URL=${REDIS_URL:-redis://redis:6379} # CHANGEME
24+
- SOURCEBOT_EE_LICENSE_KEY=${SOURCEBOT_EE_LICENSE_KEY:-}
25+
- SOURCEBOT_TELEMETRY_DISABLED=${SOURCEBOT_TELEMETRY_DISABLED:-false}
26+
27+
# For the full list of environment variables see:
28+
# https://docs.sourcebot.dev/docs/configuration/environment-variables
29+
30+
postgres:
31+
image: docker.io/postgres:${POSTGRES_VERSION:-latest}
32+
restart: always
33+
healthcheck:
34+
test: ["CMD-SHELL", "pg_isready -U postgres"]
35+
interval: 3s
36+
timeout: 3s
37+
retries: 10
38+
environment:
39+
POSTGRES_USER: postgres
40+
POSTGRES_PASSWORD: postgres # CHANGEME
41+
POSTGRES_DB: postgres
42+
ports:
43+
- 127.0.0.1:5432:5432
44+
volumes:
45+
- sourcebot_postgres_data:/var/lib/postgresql/data
46+
47+
redis:
48+
image: docker.io/redis:${REDIS_VERSION:-latest}
49+
restart: always
50+
ports:
51+
- 127.0.0.1:6379:6379
52+
healthcheck:
53+
test: ["CMD", "redis-cli", "ping"]
54+
interval: 3s
55+
timeout: 10s
56+
retries: 10
57+
volumes:
58+
- sourcebot_redis_data:/data
59+
60+
volumes:
61+
sourcebot_data:
62+
driver: local
63+
sourcebot_postgres_data:
64+
driver: local
65+
sourcebot_redis_data:
66+
driver: local

docs/docs.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
"group": "Getting Started",
2222
"pages": [
2323
"docs/overview",
24-
"docs/deployment-guide"
24+
{
25+
"group": "Deployment",
26+
"pages": [
27+
"docs/deployment/docker-compose",
28+
"docs/deployment/k8s"
29+
]
30+
}
2531
]
2632
},
2733
{

docs/docs/configuration/environment-variables.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Environment variables
33
sidebarTitle: Environment variables
44
---
55

6-
<Note>This page provides a detailed reference of all environment variables supported by Sourcebot. If you're just looking to get up and running, we recommend starting with the [deployment guide](/docs/deployment-guide) instead.</Note>
6+
<Note>This page provides a detailed reference of all environment variables supported by Sourcebot. If you're just looking to get up and running, we recommend starting with the [deployment guides](/docs/deployment/docker-compose) instead.</Note>
77

88
### Core Environment Variables
99
The following environment variables allow you to configure your Sourcebot deployment.

docs/docs/deployment-guide.mdx

Lines changed: 0 additions & 88 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: "Docker Compose"
3+
---
4+
5+
This guide will walk you through deploying Sourcebot locally or on a VM using Docker Compose. We will use the [docker-compose.yml](https://github.com/sourcebot-dev/sourcebot/blob/main/docker-compose.yml) file from the Sourcebot repository. This is the simplest way to get started with Sourcebot.
6+
7+
If you are looking to deploy onto Kubernetes, see the [Kubernetes (Helm)](/docs/deployment/k8s) guide.
8+
9+
## Get started
10+
11+
<Steps>
12+
<Step title="Requirements">
13+
- docker & docker compose. Use [Docker Desktop](https://www.docker.com/products/docker-desktop/) on Mac or Windows.
14+
</Step>
15+
<Step title="Obtain the Docker Compose file">
16+
Download the [docker-compose.yml](https://github.com/sourcebot-dev/sourcebot/blob/main/docker-compose.yml) file from the Sourcebot repository.
17+
18+
```bash wrap icon="terminal"
19+
curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/docker-compose.yml
20+
```
21+
</Step>
22+
23+
<Step title="Create a config.json">
24+
25+
In the same directory as the `docker-compose.yml` file, create a [configuration file](/docs/configuration/config-file). The configuration file is a JSON file that configures Sourcebot's behaviour, including what repositories to index, language model providers, auth providers, and more.
26+
27+
```bash wrap icon="terminal" Create example config
28+
touch config.json
29+
echo '{
30+
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
31+
// Comments are supported.
32+
// This config creates a single connection to GitHub.com that
33+
// indexes the Sourcebot repository
34+
"connections": {
35+
"starter-connection": {
36+
"type": "github",
37+
"repos": [
38+
"sourcebot-dev/sourcebot"
39+
]
40+
}
41+
}
42+
}' > config.json
43+
```
44+
</Step>
45+
46+
<Step title="Launch your instance">
47+
Update the secrets in the `docker-compose.yml` and then run Sourcebot using:
48+
49+
```bash wrap icon="terminal"
50+
docker compose up
51+
```
52+
</Step>
53+
54+
<Step title="Done">
55+
You're all set! Navigate to [http://localhost:3000](http://localhost:3000) to access your Sourcebot instance.
56+
</Step>
57+
</Steps>
58+
59+
## Next steps
60+
61+

docs/docs/deployment/k8s.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: "Kubernetes (Helm)"
3+
url: https://github.com/sourcebot-dev/sourcebot-helm-chart
4+
---

docs/docs/features/agents/review-agent.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ codebase that the agent may fetch to perform the review.
1010

1111
This agent provides codebase-aware reviews for your PRs. For each diff, this agent fetches relevant context from Sourcebot and feeds it into an LLM for a detailed review of your changes.
1212

13-
The AI Code Review Agent is [fair source](https://github.com/sourcebot-dev/sourcebot/tree/main/packages/web/src/features/agents/review-agent) and packaged in [Sourcebot](https://github.com/sourcebot-dev/sourcebot). To get started using this agent, [deploy Sourcebot](/docs/deployment-guide)
13+
The AI Code Review Agent is [fair source](https://github.com/sourcebot-dev/sourcebot/tree/main/packages/web/src/features/agents/review-agent) and packaged in [Sourcebot](https://github.com/sourcebot-dev/sourcebot). To get started using this agent, [deploy Sourcebot](/docs/deployment/docker-compose)
1414
and then follow the configuration instructions below.
1515

1616
![AI Code Review Agent Example](/images/review_agent_example.png)

docs/docs/features/ask/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ follow code nav references, and provide an answer that’s rich with inline cita
1414
<Card title="Index repos" icon="book" href="/docs/connections/overview" horizontal="true">
1515
Learn how to index your repos so you can ask questions about them
1616
</Card>
17-
<Card title="Deployment guide" icon="server" href="/docs/deployment-guide" horizontal="true">
17+
<Card title="Deployment guide" icon="server" href="/docs/deployment/docker-compose" horizontal="true">
1818
Learn how to self-host Sourcebot in a few simple steps.
1919
</Card>
2020
<Card title="Public demo" icon="globe" href="https://demo.sourcebot.dev/" horizontal="true">

0 commit comments

Comments
 (0)