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
209 changes: 209 additions & 0 deletions docs/docs/deployment-guide.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
---
title: "Deployment guide"
---

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

## Container deployment

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.


<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>

<Steps>
<Step title="Requirements">
- Docker -> use [Docker Desktop](https://www.docker.com/products/docker-desktop/) on Mac or Windows.
</Step>
<Step title="Create a config.json">
Create a `config.json` file that tells Sourcebot which repositories to sync and index:

```bash wrap icon="terminal" Create example config
touch config.json
echo '{
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
"connections": {
// comments are supported
"starter-connection": {
"type": "github",
"repos": [
"sourcebot-dev/sourcebot"
]
}
}
}' > config.json
```

This config creates a single GitHub connection named `starter-connection` that specifies [Sourcebot](https://github.com/sourcebot-dev/sourcebot) as a repo to sync. [Learn more about the config file](/docs/configuration/config-file).
</Step>

<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>


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
```

<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.
</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>


## NixOS deployment

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

<Steps>
<Step title="Flake.nix input">
Add the Sourcebot flake as an input to your NixOS configuration. This will allow you to use the Sourcebot container in your NixOS deployment.

```nix wrap icon="code" Add flake input
inputs.sourcebot.url = "github:sourcebot-dev/sourcebot";
```

Add sourcebot module to your NixOS configuration:

```nix wrap icon="code" Add module to configuration
nixosConfigurations.mysystem = nixpkgs.lib.nixosSystem {
modules = [
inputs.sourcebot.nixosModules.sourcebot
];
}
```
[Learn more about NixOS flakes](https://nixos.wiki/wiki/Flakes).
</Step>
<Step title="Setup Credentials">
Sourcebot requires a few secrets to be set up before it can run, and code host credentials can be managed using NixOS module too:

- [sops-nix](https://github.com/Mic92/sops-nix) example:

```nix wrap icon="code" sops-nix configuration
sops = {
secrets = {
sourcebot-auth-secret.owner = "sourcebot";
sourcebot-encryption-key.owner = "sourcebot";
sourcebot-gitlab-token.owner = "sourcebot";
};
templates = {
sourcebot-env = {
content = ''
AUTH_SECRET=${config.sops.placeholder.sourcebot-auth-secret}
SOURCEBOT_ENCRYPTION_KEY=${config.sops.placeholder.sourcebot-encryption-key}
GITLAB_EXAMPLE_TOKEN=${config.sops.placeholder.sourcebot-gitlab-token}
'';
};
};
};
```

- [agenix](https://github.com/ryantm/agenix) example:

```nix wrap icon="code" agenix configuration
age.secrets.sourcebot-env.file = ../secrets/sourcebot.age;
```

`sourcebot.age` file should be an environment file in the format:

```bash wrap icon="terminal" Environment file format
AUTH_SECRET=your-auth-secret
SOURCEBOT_ENCRYPTION_KEY=your-encryption-key
GITLAB_EXAMPLE_TOKEN=your-gitlab-token
```
</Step>
<Step title="Enable Sourcebot">
The following NixOS configuration will enable Sourcebot and set it up to run with the provided configuration.
Additional options could be found in the [source file](https://github.com/sourcebot-dev/sourcebot/blob/main/nix/nixosModule.nix).

```nix wrap icon="code" Enable Sourcebot service
services.sourcebot = {
enable = true;
# envFile = config.sops.templates.sourcebot-env.path; # Uncomment if using sops-nix
# envFile = config.age.secrets.sourcebot-env.path; # Uncomment if using agenix
package = pkgs.sourcebot;
logLevel = "info";
dataDir = "/data/sourcebot";
dataCacheDir = "/data/sourcebot/cache";
configPath = "${pkgs.writeText "config" (builtins.toJSON {
"$schema" = "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json";
connections = {
github-public = {
type = "github";
repos = [
"sourcebot-dev/sourcebot"
];
};
gitlab-private = {
type = "gitlab";
url = "https://gitlab.example.com";
all = true;
token = {
env = "GITLAB_EXAMPLE_TOKEN";
};
exclude = {
forks = true;
};
};
};
settings = {
resyncConnectionIntervalMs = 1000 * 60 * 60 * 24 * 7; # 1 week
reindexIntervalMs = 1000 * 60 * 60 * 24 * 7; # 1 week
maxRepoIndexingJobConcurrency = 1000; # 8 default
maxConnectionSyncJobConcurrency = 1000; # 8 default
maxRepoGarbageCollectionJobConcurrency = 1000; # 8 default
Comment on lines +176 to +178
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Unusually high concurrency values in example.

The concurrency settings are set to 1000 while comments indicate the default is 8. These values seem extremely high for an example configuration and could cause resource exhaustion if users copy this verbatim. Consider using more reasonable values or the defaults.

Proposed fix with more reasonable example values
                 settings = {
                   resyncConnectionIntervalMs = 1000 * 60 * 60 * 24 * 7; # 1 week
                   reindexIntervalMs = 1000 * 60 * 60 * 24 * 7; # 1 week
-                  maxRepoIndexingJobConcurrency = 1000; # 8 default
-                  maxConnectionSyncJobConcurrency = 1000; # 8 default
-                  maxRepoGarbageCollectionJobConcurrency = 1000; # 8 default
+                  maxRepoIndexingJobConcurrency = 8;
+                  maxConnectionSyncJobConcurrency = 8;
+                  maxRepoGarbageCollectionJobConcurrency = 8;
                 };
📝 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
maxRepoIndexingJobConcurrency = 1000; # 8 default
maxConnectionSyncJobConcurrency = 1000; # 8 default
maxRepoGarbageCollectionJobConcurrency = 1000; # 8 default
maxRepoIndexingJobConcurrency = 8;
maxConnectionSyncJobConcurrency = 8;
maxRepoGarbageCollectionJobConcurrency = 8;
🤖 Prompt for AI Agents
In `@docs/docs/deployment-guide.mdx` around lines 176 - 178, The example sets
extremely high concurrency values for maxRepoIndexingJobConcurrency,
maxConnectionSyncJobConcurrency, and maxRepoGarbageCollectionJobConcurrency
(1000) which contradicts the “8 default” comment; change these example values to
reasonable numbers (e.g., 8 or 16) or revert to the documented defaults and
update the inline comments to match the chosen values so users won’t copy unsafe
settings; locate and edit the three symbols maxRepoIndexingJobConcurrency,
maxConnectionSyncJobConcurrency, and maxRepoGarbageCollectionJobConcurrency in
the example block and adjust both the numeric values and their trailing comments
to be consistent.

};
})}";
};
```
</Step>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: please add the Login and Done steps from the container deployment here. Copy and paste should be fine!


<Step title="Complete onboarding">
Navigate to `http://localhost:7734` and complete the onboarding flow.
Comment on lines +185 to +186
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, find the deployment guide file
fd "deployment-guide" --type f

# Then read the relevant lines to understand the context
echo "=== Checking container deployment port (around line 69) ==="
sed -n '60,80p' docs/docs/deployment-guide.mdx

echo -e "\n=== Checking NixOS deployment port (around line 185-186) ==="
sed -n '175,195p' docs/docs/deployment-guide.mdx

Repository: sourcebot-dev/sourcebot

Length of output: 2014


🏁 Script executed:

#!/bin/bash
# Search for NixOS module files and port configuration
echo "=== Searching for NixOS module files ==="
fd "\.nix$" | grep -E "(module|nixos|deployment)" | head -20

echo -e "\n=== Searching for port 7734 in the codebase ==="
rg -n "7734" --type-list

echo -e "\n=== Searching for port 3000 in the codebase ==="
rg -n "3000" --type-list

Repository: sourcebot-dev/sourcebot

Length of output: 1040


🏁 Script executed:

#!/bin/bash
# Check the NixOS module for port configuration
echo "=== Reading NixOS module file ==="
cat -n nix/nixosModule.nix | head -100

echo -e "\n=== Searching for port configuration in nixos module ==="
grep -n "port\|7734\|3000" nix/nixosModule.nix || echo "No matches found"

echo -e "\n=== Check full nixos module ==="
wc -l nix/nixosModule.nix

Repository: sourcebot-dev/sourcebot

Length of output: 4957


🏁 Script executed:

#!/bin/bash
# Correct search for port references
echo "=== Searching for port 7734 ==="
rg "7734" 

echo -e "\n=== Searching for port 3000 ==="
rg "3000"

echo -e "\n=== Searching for port configuration in general ==="
rg "port.*=" --type nix | head -20

Repository: sourcebot-dev/sourcebot

Length of output: 29636


Consider clarifying why NixOS deployment uses port 7734 instead of 3000.

The NixOS deployment defaults to port 7734, while the container deployment uses port 3000. Since the NixOS module explicitly configures 7734 as the default port, this is intentional. However, the documentation could benefit from a brief note explaining this difference to avoid user confusion when comparing deployment options.

🤖 Prompt for AI Agents
In `@docs/docs/deployment-guide.mdx` around lines 185 - 186, Update the "Complete
onboarding" Step to add a one-sentence clarification about port differences:
explain that the NixOS module intentionally defaults to port 7734 (hence the
documentation uses http://localhost:7734) while the container deployment exposes
port 3000, and mention that this is configured in the NixOS module so users
should not expect the same port as containers. Reference the Step title
"Complete onboarding" when making the edit and keep the note brief and factual.

</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>



## Next steps
---

<CardGroup cols={3}>
<Card title="Index your code" icon="code" href="/docs/connections/overview">
Learn how to index your code using Sourcebot
</Card>
<Card title="Language models" icon="brain" href="/docs/configuration/language-model-providers">
Learn how to configure language model providers to start using [Ask Sourcebot](/docs/features/ask/overview)
</Card>
<Card title="Authentication" icon="lock" href="/docs/configuration/auth/overview">
Learn more about how to setup SSO, email codes, and other authentication providers.
</Card>
</CardGroup>
133 changes: 133 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading