Deploying your own Sweep instance via Docker
π We recently changed our license to theΒ Elastic License V2 (opens in a new tab) to allow Sweep for commercial usage.
This is the guide for self-deploying Sweep. If you would like to use our hosted version, please visit https://sweep.dev (opens in a new tab). If you would like to develop on Sweep, check out development (opens in a new tab).
Video Guide (~5 minutes)
After finishing the steps in the video, please complete these two steps:
- Add your GitHub App name to the secrets as
GITHUB_BOT_USERNAME
- Complete the
Set Webhook URL in GitHub
step once your Digital Ocean instance has finished deploying.
Alternatively, we have written instructions below.
1. Create GitHub App
We created an app using npm
to make it easier to set up the GitHub App. If you do not have it installed, install it here (opens in a new tab). If you would like ot set it up yourself, scroll down to the Manual GitHub App Setup section.
Run this GitHub App locally! This tool is only used for creating the GitHub App, not hosting Sweep.
First, open a terminal and run the following commands (RUN LOCALLY):
git clone https://github.com/sweepai/sweep
cd sweep/self_deploy
npm install
npm start
Second, open http://localhost:3000 (opens in a new tab) in your browser, and:
- Click the "Register GitHub App" button.
- Click the green "Create GitHub App for USERNAME" button.
- Pick where to install the app and then click the green "Install" button. This will take you to the app settings page.
- Click the small "App settings" button.
Now, stop the server by pressing Ctrl+C
in the terminal. Once it has stopped, open the .env
file with a text editor in the sweep/self_deploy
directory. You should see something like this:
APP_ID=123456
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
WEBHOOK_SECRET=213921898f9as8f92139128989f
GITHUB_CLIENT_ID=Iv1.123218f182131
GITHUB_CLIENT_SECRET=6g626312b212142132121321412
Add two variables to the end of the file:
- GITHUB_BOT_USERNAME=sweep-example-name
- WHITELISTED_USERS=your-username,other-username,another-username
...
GITHUB_BOT_USERNAME=sweep-example-name
WHITELISTED_USERS=your-username,other-username,another-username
You should have the following environment variables:
APP_ID=123456
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
WEBHOOK_SECRET=213921898f9as8f92139128989f
GITHUB_CLIENT_ID=Iv1.123218f182131
GITHUB_CLIENT_SECRET=6g626312b212142132121321412
GITHUB_BOT_USERNAME=sweep-example-name
WHITELISTED_USERS=your-username,other-username,another-username
2. OpenAI API Token
Please create an OpenAI API token at https://platform.openai.com/account/api-keys (opens in a new tab). You will need this later. Also, if you have access to the 32k model, please set OPENAI_DO_HAVE_32K_MODEL_ACCESS=true
. If you have a beefier machine and want higher quality search, change the sentence transformers model to sentence-transformers/all-mpnet-base-v2
.
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_DO_HAVE_32K_MODEL_ACCESS=false
After following one of the above sections, you should have the following environment variables:
APP_ID=123456
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
WEBHOOK_SECRET=213921898f9as8f92139128989f
GITHUB_CLIENT_ID=Iv1.123218f182131
GITHUB_CLIENT_SECRET=6g626312b212142132121321412
GITHUB_BOT_USERNAME=sweep-example-name
WHITELISTED_USERS=your-username,other-username,another-username
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_DO_HAVE_32K_MODEL_ACCESS=false
3. Hosting Sweep
Starting here it gets more involved so if you run into issues, please reach out to us on Discord (opens in a new tab) or open a GitHub issue (opens in a new tab) (ironic, we know!). We are online, please ping us @kevin, @william, and @luke.
1. Create Instance
Recommended specs:
- OS: Ubuntu
- RAM: 16 GB
- CPU: 2 vCPUs
- Storage: 50 GB
2. Install Docker and docker compose
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update -y
sudo apt install docker-ce -y
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker ${USER}
3. Configure .env
and pull Image
Run the docker client if you are on Mac/Windows.
git clone https://github.com/sweepai/sweep
cd sweep
vim .env
docker compose pull
And copy the following into the file:
# Step 1
APP_ID=123456
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
WEBHOOK_SECRET=213921898f9as8f92139128989f
GITHUB_CLIENT_ID=Iv1.123218f182131
GITHUB_CLIENT_SECRET=6g626312b212142132121321412
GITHUB_BOT_USERNAME=sweep-example-name
WHITELISTED_USERS=your-username,other-username,another-username
# Step 2
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_DO_HAVE_32K_MODEL_ACCESS=false
4. Launch Docker Image
docker compose up # Add -d to run in background
5. Update GitHub Webhook URL
First, get the IP address of your instance, and add the port Sweep is deployed to (in this case, 8080):
http://ip:8080
Navigating to this link should look like this:
- Copy this link to your clipboard.
- Go to your GitHub App and paste this link into the
General
tabWebhook URL
field. Ensure SSL verification remains active.
4. Using Sweep
Finally, you can use Sweep by creating a new issue with a title prefixed with Sweep:
, like Sweep: add comments to BaseIndex.tsx
and watch the magic happen!
For more details on using Sweep, see our tutorial (opens in a new tab) and advanced usage (opens in a new tab) guides. For extra deployment configurations like Azure, and Redis (coming soon!) check out our extra self-hosting configs (opens in a new tab).
You have successfully deployed Sweep!
*There's additional configurable settings like Redis caching and GPU-accelerated embeddings that we use for our hosted product that we can document further for self-hosting. If this interests you please contact us at https://discord.gg/sweep (opens in a new tab). *
Alternative steps:
If you successfully deployed Sweep, you can skip this section.
Alternative to 3: Deploying Locally
If you do not want to deploy on the cloud and would prefer to deploy on your local machine, you can do so by following the steps below.
You need to install Docker (opens in a new tab) to host Sweep.
Pull our image from Docker Hub:
git clone https://github.com/sweepai/sweep
cd sweep
docker compose pull
It may take 5-10 minutes to download the image and you can move on to the next step while it's downloading.
Create a .env
file with the contents from steps 1 and 2. Then in the same directory, run:
docker compose up # Add -d to run in background
We're going to use Ngrok (opens in a new tab) for a reverse proxy.
Sign up for an Ngrok account and install the CLI from https://dashboard.ngrok.com/signup (opens in a new tab). Your terminal must be in the same directory as your ngrok installation. Start the reverse proxy with ./ngrok http 8080
. The second last line should say something like
Forwarding https://4d8d8bf053be.ngrok.app -> http://localhost:8080
Then proceed with step 4.
Alternative to 1: Manual GitHub App Setup
If you would like to use Sweep on GitHub organizations, please follow the steps below.
Register a new GitHub App, following this guide (opens in a new tab) (3 minutes). You should return here after step 16(it's not as bad as it seems, most steps are optional).
Use the below as a reference:
Set the Repository Permissions (7 selected):
Scope | Permissions |
---|---|
actions | read |
checks | read |
contents | read & write |
commit statuses | read & write |
issues | read & write |
metadata | read |
pull requests | read & write |
workflows | read & write |
Subscribe to events |
---|
check run |
check suite |
commit comment |
create |
issue comment |
issues |
label |
pull request |
pull request review |
pull request review comment |
pull request thread |
push |
status |
workflow job |
workflow run |
Put a placeholder url for now (ex: https://github.com/sweepai/sweep/ (opens in a new tab)). Generate a private key (it should prompt you at the top of the screen, or alternatively follow this guide (opens in a new tab)) and save it for later.
Once the private key is downloaded, format it for the next step:
echo -e "paste key here" | tr '\n' ' ' | sed 's/ /\\n/g'
And, save the output for later in the following format:
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
You will also need your app ID, which is the number at the top of the page. This is your app-id
for step 2.
Click Install App to install it on your account or organization. Point it to a repo which you want to use Sweep on. This repo cannot be empty. If you don't have a good repo at hand, check out our tutorial on running Sweep on Docusaurus (opens in a new tab).
Store the following constants for later:
APP_ID=123456
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
GITHUB_BOT_USERNAME=sweep-example-name
Alternative to 3: Deploy DigitalOcean App
As Sweep is Dockerized, you can deploy this anywhere but for this guide, we will deploy it on Digital Ocean for simplicity. If you would like to run it locally, you can follow the section in the dropdown at the bottom of this guide.
First, click the following:
1. Skip Resources Page
2. Set Environment Variables
In the Environment Variable Editor
, copy and paste the environment variables from above like so:
Click Save
to close the Bulk Editor, then click Save
again to save the varaibles.
It is important that you click save twice, otherwise the variables will not be saved.
APP_ID=1234
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
GITHUB_BOT_USERNAME=sweep-example-name
# These three are from step 2.
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_DO_HAVE_32K_MODEL_ACCESS=false
3. Info
Modify any information as needed, then click Next
.
4. Review: Update Instance Resource Size
First, click Edit Plan
in the Billing
section.
Then, set the Instance Size.
Please select an instance with at least 2 GB RAM. The default 1 GB RAM instance will not work.
5. Create Resources!
Simply click the button to create the instance.
6. Set Webhook URL in GitHub (Important)
Once the resource is created, you should get a link like this:
Navigating to this link should look like this:
- Copy this link to your clipboard.
- Go to your GitHub App and paste this link into the
General
tabWebhook URL
field. Ensure SSL verification remains active.