Reference Repositories
Sourcegraph provides reference repositories with branches corresponding to the version of Sourcegraph you wish to deploy for each supported deployment type. The reference repository contains everything you need to spin up and configure your instance depending on your deployment type.
Deployment type | Link to reference repository |
---|---|
Kubernetes | https://github.com/sourcegraph/deploy-sourcegraph-k8s |
Helm | https://github.com/sourcegraph/deploy-sourcegraph-helm |
Docker and Docker Compose | https://github.com/sourcegraph/deploy-sourcegraph-docker |
Create a private copy of a Reference Repository
Step 1: Create an empty repository
Follow the official GitHub docs on creating a new empty repository.
Step 2: Set the environment variables
Export the following environment variables for the next steps.
SG_DEPLOY_REPO_NAME
: name of the deployment repositorydeploy-sourcegraph-k8s
for Kubernetes with Kustomize deploymentdeploy-sourcegraph-docker
for Docker and Docker Compose deployment
DEPLOY_GITHUB_USERNAME
: the account name that is hosting the empty repository created in step 1SG_PRIVATE_DEPLOY_REPO_NAME
: default to the same name as $SG_DEPLOY_REPO_NAMESG_DEPLOY_VERSION
: latest version number of Sourcegraph
Update the environment variables in the command below before running it in your terminal:
BASHexport SG_DEPLOY_GITHUB_USERNAME="YOUR_USERNAME" export SG_DEPLOY_REPO_NAME="deploy-sourcegraph-k8s" export SG_PRIVATE_DEPLOY_REPO_NAME="$SG_DEPLOY_REPO_NAME" export SG_DEPLOY_VERSION="v5.3.0"
Step 3: Create remote and local copies
Once the required environment variables are exported, run the following commands in the same terminal:
BASHgit clone --bare https://github.com/sourcegraph/$SG_DEPLOY_REPO_NAME cd $DEPLOY_REPO.git git push --mirror https://github.com/SG_DEPLOY_GITHUB_USERNAME/$SG_PRIVATE_DEPLOY_REPO_NAME.git cd .. rm -rf $DEPLOY_REPO.git git clone https://github.com/SG_DEPLOY_GITHUB_USERNAME/$SG_PRIVATE_DEPLOY_REPO_NAME.git
Step 4: Create a release branch
Create a release
branch to track all of your customizations to Sourcegraph. This branch will be used to upgrade Sourcegraph and install your Sourcegraph instance.
BASHcd $SG_PRIVATE_DEPLOY_REPO_NAME git checkout $SG_DEPLOY_VERSION -b release-$SG_DEPLOY_VERSION
You can now deploy using your private copy of the repository you've just created. Please follow the installation and configuration docs for your specific deployment type for next steps.
Update your private copy
Before you can upgrade Sourcegraph, you will first update your private copy with the upstream branch, and then merge the upstream release tag for the next minor version into your release branch.
In the following example, the release branch is being upgraded to v5.6.2535.
BASHexport YOUR_RELEASE_BRANCH=release-$SG_DEPLOY_VERSION # first, checkout the release branch git checkout $YOUR_RELEASE_BRANCH # fetch updates git fetch upstream # merge the upstream release tag into your release branch git checkout $YOUR_RELEASE_BRANCH git merge v5.6.2535
A standard upgrade occurs between two minor versions of Sourcegraph. If you are looking to jump forward several versions, you must perform a multi-version upgrade instead.