Skip to content

Commit 8dbb6fc

Browse files
feat(v5): Setup wizard (#1212)
1 parent 0d17b3e commit 8dbb6fc

18 files changed

Lines changed: 2462 additions & 57 deletions

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ services:
1515
volumes:
1616
- ./config.json:/data/config.json
1717
- sourcebot_data:/data
18+
env_file:
19+
- path: .env
20+
required: false
1821
environment:
1922
- CONFIG_PATH=/data/config.json
2023
- AUTH_URL=${AUTH_URL:-http://localhost:3000}
2124
- AUTH_SECRET=${AUTH_SECRET:-000000000000000000000000000000000} # CHANGEME: generate via `openssl rand -base64 33`
2225
- SOURCEBOT_ENCRYPTION_KEY=${SOURCEBOT_ENCRYPTION_KEY:-000000000000000000000000000000000} # CHANGEME: generate via `openssl rand -base64 24`
2326
- DATABASE_URL=${DATABASE_URL:-postgresql://postgres:postgres@postgres:5432/postgres} # CHANGEME
2427
- REDIS_URL=${REDIS_URL:-redis://redis:6379} # CHANGEME
25-
- SOURCEBOT_EE_LICENSE_KEY=${SOURCEBOT_EE_LICENSE_KEY:-}
2628

2729
# For the full list of environment variables see:
2830
# https://docs.sourcebot.dev/docs/configuration/environment-variables

docs/docs/deployment/docker-compose.mdx

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,68 @@
22
title: "Docker Compose"
33
---
44

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](https://github.com/sourcebot-dev/sourcebot). This is the simplest way to get started with Sourcebot.
5+
This guide will walk you through deploying Sourcebot locally or on a VM using [Docker Compose](https://github.com/sourcebot-dev/sourcebot/blob/main/docker-compose.yml). This is the simplest way to get started with Sourcebot.
66

77
If you are looking to deploy onto Kubernetes, see the [Kubernetes (Helm)](/docs/deployment/k8s) guide.
88

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>
9+
## System requirements
10+
- RAM: Ensure your environment has at least 4GB of RAM. Insufficient memory can cause processes to crash.
11+
- Docker & Docker Compose: Make sure both are installed and up-to-date.
12+
- Node.js 18+: Required for the setup CLI
13+
14+
## Option 1: Setup CLI
15+
16+
The setup CLI will guide you through configuring your Sourcebot instance to connect to your code hosts and LLM providers. From a empty folder, run the following command:
17+
18+
```
19+
npx setup-sourcebot
20+
```
21+
22+
<Frame>
23+
<img src="/images/setup_sourcebot_splash.png" alt="npx setup-sourcebot" />
24+
</Frame>
25+
26+
## Option 2: Manual steps
27+
28+
### Obtain the Docker Compose file
29+
30+
Download the [docker-compose.yml](https://github.com/sourcebot-dev/sourcebot/blob/main/docker-compose.yml) file from the Sourcebot repository.
31+
32+
```bash wrap icon="terminal"
33+
curl -o docker-compose.yml https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/docker-compose.yml
34+
```
35+
36+
### Create a config.json
37+
38+
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.
39+
40+
```bash wrap icon="terminal" Create example config
41+
touch config.json
42+
echo '{
43+
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
44+
// Comments are supported.
45+
// This config creates a single connection to GitHub.com that
46+
// indexes the Sourcebot repository
47+
"connections": {
48+
"starter-connection": {
49+
"type": "github",
50+
"repos": [
51+
"sourcebot-dev/sourcebot"
52+
]
53+
}
54+
}
55+
}' > config.json
56+
```
57+
58+
### Launch your instance
59+
60+
Update the secrets in the `docker-compose.yml` and then run Sourcebot using:
61+
62+
```bash wrap icon="terminal"
63+
docker compose up
64+
```
65+
66+
Navigate to [http://localhost:3000](http://localhost:3000) to access your Sourcebot instance.
5867

5968
## Next steps
6069

77.8 KB
Loading

packages/setupWizard/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# setup-sourcebot
2+
3+
Interactive CLI wizard for setting up a self-hosted [Sourcebot](https://sourcebot.dev) instance.
4+
5+
## Usage
6+
7+
Run from an empty directory:
8+
9+
```bash
10+
npx setup-sourcebot
11+
```
12+
13+
The wizard walks you through:
14+
15+
- **Code hosts** — GitHub, GitLab, Bitbucket (Cloud or Data Center), Azure DevOps (Cloud or Server), Gitea, Gerrit, a local folder of cloned repos, or any other git URL.
16+
- **AI providers** (optional) — Anthropic, OpenAI, Google Gemini, Google Vertex, DeepSeek, Mistral, xAI, OpenRouter, OpenAI-compatible endpoints, Amazon Bedrock, or Azure OpenAI. Powers [Ask](https://docs.sourcebot.dev/docs/features/ask/overview).
17+
18+
## Requirements
19+
20+
- Node.js 18+
21+
- Docker and Docker Compose
22+
23+
## Docs
24+
25+
Full deployment guide: [docs.sourcebot.dev/docs/deployment/docker-compose](https://docs.sourcebot.dev/docs/deployment/docker-compose)

packages/setupWizard/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "setup-sourcebot",
3+
"version": "0.1.1",
4+
"description": "CLI wizard for creating a Sourcebot configuration.",
5+
"type": "module",
6+
"bin": "./dist/index.js",
7+
"scripts": {
8+
"build": "tsc",
9+
"watch": "tsc --watch",
10+
"dev": "tsx src/index.ts",
11+
"prepublishOnly": "yarn build"
12+
},
13+
"dependencies": {
14+
"@inquirer/prompts": "^8.4.3",
15+
"chalk": "^5.6.2",
16+
"inquirer-select-pro": "^1.0.0-alpha.9",
17+
"ora": "^9.4.0"
18+
},
19+
"devDependencies": {
20+
"@sourcebot/schemas": "workspace:^",
21+
"@types/node": "^22.7.5",
22+
"tsx": "^4.21.0",
23+
"typescript": "^5.6.2"
24+
},
25+
"engines": {
26+
"node": ">=18"
27+
},
28+
"files": [
29+
"dist",
30+
"README.md"
31+
]
32+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { checkbox, confirm, input, password, select } from '@inquirer/prompts';
2+
import type { AzureDevOpsConnectionConfig } from '@sourcebot/schemas/v3/azuredevops.type';
3+
import type { CollectResult, EnvVars } from './utils.js';
4+
import { multiInput, note, toEnvKey } from './utils.js';
5+
6+
export async function collectAzureDevOpsConfig(connectionName: string): Promise<CollectResult> {
7+
const env: EnvVars = {};
8+
9+
const deploymentType = await select<'cloud' | 'server'>({
10+
message: 'Which Azure DevOps deployment?',
11+
choices: [
12+
{ value: 'cloud', name: 'Azure DevOps Cloud', description: 'dev.azure.com' },
13+
{ value: 'server', name: 'Azure DevOps Server', description: 'self-hosted' },
14+
],
15+
});
16+
17+
const config: AzureDevOpsConnectionConfig = {
18+
type: 'azuredevops',
19+
deploymentType,
20+
token: { env: '' },
21+
};
22+
23+
if (deploymentType === 'server') {
24+
const url = await input({
25+
message: 'Azure DevOps Server URL (e.g. https://ado.example.com)',
26+
validate: (v) => {
27+
if (!v?.trim()) {
28+
return 'URL is required';
29+
}
30+
if (!/^https?:\/\//.test(v)) {
31+
return 'Must start with http:// or https://';
32+
}
33+
return true;
34+
},
35+
});
36+
config.url = url;
37+
38+
const useTfsPath = await confirm({
39+
message: 'Use legacy TFS path format (/tfs in API URLs)?',
40+
default: false,
41+
});
42+
if (useTfsPath) {
43+
config.useTfsPath = true;
44+
}
45+
}
46+
47+
note(
48+
[
49+
'Create a Personal Access Token at:',
50+
deploymentType === 'cloud'
51+
? ' https://dev.azure.com/<your-org>/_usersSettings/tokens'
52+
: ' <your-server-url>/_usersSettings/tokens',
53+
'Grant `Code (Read)` scope so Sourcebot can find and clone your repos.',
54+
].join('\n'),
55+
'Azure DevOps Personal Access Token',
56+
);
57+
58+
const envKey = toEnvKey(connectionName, 'TOKEN');
59+
const token = await password({
60+
message: `Azure DevOps Personal Access Token (stored as ${envKey})`,
61+
mask: true,
62+
validate: (v) => !v?.trim() ? 'Token is required' : true,
63+
});
64+
env[envKey] = token;
65+
config.token = { env: envKey };
66+
67+
const orgLabel = deploymentType === 'cloud' ? 'organization' : 'collection';
68+
const orgLabelPlural = deploymentType === 'cloud' ? 'Organizations' : 'Collections';
69+
70+
const targets = await checkbox<string>({
71+
message: 'What do you want to index?',
72+
choices: [
73+
{ value: 'orgs', name: orgLabelPlural, description: `all projects in a ${orgLabel}` },
74+
{ value: 'projects', name: 'Specific projects', description: `${orgLabel}/project format` },
75+
{ value: 'repos', name: 'Specific repositories', description: `${orgLabel}/project/repo format` },
76+
],
77+
required: true,
78+
});
79+
80+
if (targets.includes('orgs')) {
81+
config.orgs = await multiInput({
82+
message: `${orgLabelPlural} to index`,
83+
});
84+
}
85+
86+
if (targets.includes('projects')) {
87+
config.projects = await multiInput({
88+
message: `Projects to index (${orgLabel}/project)`,
89+
});
90+
}
91+
92+
if (targets.includes('repos')) {
93+
config.repos = await multiInput({
94+
message: `Repositories to index (${orgLabel}/project/repo)`,
95+
});
96+
}
97+
98+
return { connections: [{ config }], env };
99+
}

0 commit comments

Comments
 (0)