Changing deployment methods after initial setup requires a full redeployment and database migration. Choose the right method for your long-term needs before going to production.
- Docker Compose
- Kubernetes (Helm)
Docker Compose deployment
Docker Compose runs all Sourcegraph services as containers on a single host. It is easier to operate than Kubernetes and works well for teams up to a few thousand users.Prerequisites
- Docker v20.10.0 or later
- Docker Compose v1.29.0 or later (Docker Swarm mode is not supported)
- A Linux server with SSD storage (see system requirements)
- A Sourcegraph Enterprise license for instances with more than 10 users
Installation
1
Fork the deployment repository
The
sourcegraph/deploy-sourcegraph-docker repository contains the docker-compose.yaml and all supporting configuration.Create a private copy of this repository in your own code host. Storing your customizations in version control makes upgrades much simpler — you track changes as a diff against the upstream repository.2
Create a release branch
Clone your private repository and create a
release branch pinned to the version you want to install:3
Customize the instance
Do not edit
docker-compose.yaml directly. Instead, create a docker-compose.override.yaml file in the same directory. The override file is merged with the base config, so your changes survive upstream updates without merge conflicts.Common customizations in the override file:- Adjust CPU and memory limits for individual services
- Add replicas for high-traffic services
- Connect to an external PostgreSQL or Redis
- Set environment variables
- Mount custom TLS certificates
release branch.4
Clone to the production server
On your production server, clone the
release branch:5
Start Sourcegraph
From the Check that the frontend is healthy:Once the
docker-compose directory, start all services:sourcegraph-frontend-0 container shows as healthy, navigate to your server’s IP or hostname on port 80. You will be prompted to create the initial site admin account.6
Apply site configuration
After signing in as the initial admin, go to Site admin > Configuration to set your
externalURL, connect code hosts, configure authentication, and add your license key. See Site configuration for details.Upgrading (Docker Compose)
Upgrades are performed by updating therelease branch to a newer version tag and redeploying.1
Fetch upstream tags
2
Merge the new version
docker-compose.override.yaml should not conflict with the base file.3
Pull new images and restart
On the production server, pull the updated repository and restart services:
Resource requirements
Use the table below to estimate the resources needed for your deployment. If you fall between sizes, choose the larger one.
Recommended cloud instance types:
After deployment
Once Sourcegraph is running, complete the initial setup:- Set
externalURLin site config to your instance’s public URL. - Add code host connections so Sourcegraph can clone and index your repositories.
- Configure authentication with your identity provider.
- Apply your license key to unlock Enterprise features.
- Configure SMTP so Sourcegraph can send email notifications.