In teams where Sourcegraph is a critical piece of infrastructure, it can often be desirable to check the Sourcegraph configuration into version control.
As of Sourcegraph v3.4+, this is possible for site configuration, critical configuration, and external services configuration
Loading configuration in this manner has two important drawbacks:
Set the environment variable below on all frontend
containers (cluster deployment) or on the server
container (single-container Docker deployment):
CRITICAL_CONFIG_FILE=critical.json
critical.json
should contain the management console configuration that you would otherwise enter through the management console UI.
You should also add to the management-console
container (cluster deployment) or to the server
container (single-container Docker deployment) the following:
DISABLE_CONFIG_UPDATES=true
Set the environment variable below on all frontend
containers (cluster deployment) or on the server
container (single-container Docker deployment):
SITE_CONFIG_FILE=site.json
site.json
contains the site configuration, which you would otherwise edit through the in-app site configuration editor.
If you want to allow edits to be made through the web UI (which will be overwritten with what is in the file on a subsequent restart), you may additionally set SITE_CONFIG_ALLOW_EDITS=true
. Note that if you do enable this, it is your responsibility to ensure the configuration on your instance and in the file remain in sync.
Set the environment variable below on all frontend
containers (cluster deployment) or on the server
container (single-container Docker deployment):
EXTSVC_CONFIG_FILE=extsvc.json
extsvc.json
contains a JSON object that specifies all of your external services in a single JSONC file:
{ "GITHUB": [ { // First GitHub external service configuration: literally the JSON object from the external service config editor. "authorization": {}, "url": "https://github.com", "token": "...", "repositoryQuery": ["affiliated"] }, { // Second GitHub external service configuration: literally the JSON object from the external service config editor. ... }, ], "PHABRICATOR": [ { // First Phabricator external service configuration: literally the JSON object from the external service config editor. ... }, ] }
You can find a full list of valid top-level keys here.
If you want to allow edits to be made through the web UI (which will be overwritten with what is in the file on a subsequent restart), you may additionally set EXTSVC_CONFIG_ALLOW_EDITS=true
. Note that if you do enable this, it is your responsibility to ensure the configuration on your instance and in the file remain in sync.
As mentioned earlier, when configuration is loaded via this manner Sourcegraph can no longer persist the automatic migrations to configuration it sometimes performs on upgrades.
It will still perform such migrations on the configuration loaded from file, it just cannot persist such migrations back to file.
When you upgrade Sourcegraph versions, you should do the following to ensure your configurations do not become invalid:
Currently, site admins are responsible for creating the ConfigMap resource that maps the above environment variables to files on the container disk.
(If you need assistance with this, please contact us.)