-
Notifications
You must be signed in to change notification settings - Fork 215
Nix support #371
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?
Nix support #371
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| }; | ||
| })}"; | ||
| }; | ||
| ``` | ||
| </Step> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please add the |
||
|
|
||
| <Step title="Complete onboarding"> | ||
| Navigate to `http://localhost:7734` and complete the onboarding flow. | ||
|
Comment on lines
+185
to
+186
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 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.mdxRepository: 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-listRepository: 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.nixRepository: 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 -20Repository: sourcebot-dev/sourcebot Length of output: 29636 Consider clarifying why NixOS deployment uses port 7734 instead of 3000. The NixOS deployment defaults to port 🤖 Prompt for AI Agents |
||
| </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> | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Unusually high concurrency values in example.
The concurrency settings are set to
1000while comments indicate the default is8. 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
🤖 Prompt for AI Agents