Setting up Docker applications with multiple containers like Sourcegraph using Docker Compose allows us to start all the applications with a single command. It also makes configuring the applications easier through updating the docker-compose.yaml and docker-compose.override.yaml files. Please see the official Docker Compose docs to learn more about Docker Compose.
This guide will take you through how to install Sourcegraph with Docker Compose on a server, which could be the local machine, a server on a local network, or cloud-hosted server. You can also follow one of the available cloud-specific guides listed below to prepare and install Sourcegraph on a supported cloud environment:
PrerequisitesInstallation StepsWARNING: Running Sourcegraph on Windows or
ARM
/ARM64
images is not supported for production deployments.
A step by step guide to install Sourcegraph with Docker Compose.
OverviewStep 1: Fork the deployment repositoryNOTE: This guide is not limited to GitHub users. You can create a copy of the deployment repository in any code host.
sourcegraph/deploy-sourcegraph-docker
is the deployment repository for Docker Compose---it contains everything you need to install and configure a Sourcegraph Docker Compose instance.
We strongly recommend you to deploy Sourcegraph using your own fork (or private copy) of the deployment repository as this allows you to track customizations made to the Sourcegraph docker-compose.yaml easily. It also makes upgrading your instance easier in the future.
NOTE: When forking the repository, make sure the box labeled, "Copy the master branch only", is unchecked. Checking this box will prevent the repository tags from being copied and will result in an error in a later step.
Create a public or private copy of the deployment repositoryWARNING: In GitHub, the forks of public repositories are also public. Create a private copy following the official docs on duplicating a repository is strongly recommended if you plan to store secrets (SSL certificates, external Postgres credentials, etc.) within the repository. However, the preferable approach would be to use a Secrets Management Service.
Use the GitHub GUI to create a public fork of the sourcegraph/deploy-sourcegraph-docker deployment repository
Detailed instruction on creating a private copy Using a private copy of the deployment repository1. Create an empty private repository, for example <you/private-repository>
in GitHub.
2. Bare clone the deployment repository.
git clone --bare https://github.com/sourcegraph/deploy-sourcegraph-docker/
3. Navigate to the bare clone and mirror push it to your private repository.
cd deploy-sourcegraph-docker.git
git push --mirror https://github.com/<you/private-repository>.git
4. Remove your local bare clone.
cd ..
rm -rf deploy-sourcegraph-docker.git
5. Private repository clone URL
If you are deploying using our start up scripts, please check with your code host on how to generate a URL for cloning private repository For example, GitHub users can include their personal access token to clone repositories they have access to using the following URL:
# Please make sure to discard the token after the deployment for security purpose
https://<PERSONAL-ACCESS-TOKEN>@github.com/<USERNAME>/<REPO>.git
Configure your deployment repository
Continue with the following steps after you have created a public or private copy of the deployment repository:
1. Clone the publicly forked (or privately cloned) repository to your local machine.
git clone https://github.com/<you/private-repository>.git
2. Add the deployment repository maintained by Sourcegraph as the remote upstream
.
git remote add upstream https://github.com/sourcegraph/deploy-sourcegraph-docker
3. Create a new branch called release
off the latest version of Sourcegraph
# Specify the version you want to install export SOURCEGRAPH_VERSION=v6.6.2517 # Check out the selected version for use, in a new branch called "release" git checkout $SOURCEGRAPH_VERSION -b releaseStep 2: Configure the Instance
You can find the default docker-compose.yaml file inside the deployment repository.
If you would like to make changes to the default configurations, we highly recommend you create a new file called docker-compose.override.yaml
in the same directory where the default docker-compose.yaml file is located, and make your customizations inside the docker-compose.override.yaml file.
Please make sure to commit any changes to your release
branch.
For detailed instructions on how to configure the instance using an override file, please refer to the configuration docs.
Step 3: Clone the release branchNOTE: Using an override file to customize your Sourcegraph instance is highly recommended as it is the best way to prevent merge conflicts during upgrades.
Now that you have customized your instance and published the changes to your code host, you will need to clone the newly configured release
branch onto the production server:
git clone --branch release https://github.com/<you/private-repository>.git
Step 4: Start SourcegraphNOTE: The
docker-compose.yaml
file currently depends on configuration files that live in the repository, so you must have the entire repository cloned onto your server.
On the production server, run the following command inside the ./docker-compose directory to build and start Sourcegraph:
# Go to the docker-compose configuration directory
cd docker-compose
# Start Sourcegraph with Docker Compose
docker compose up
# OR you can start Sourcegraph with Docker Compose in a detached mode
docker compose up -d
To check if the server is ready, the sourcegraph-frontend-0
service must be displayed as healthy:
# Check the health status for sourcegraph-frontend-0
docker ps --filter="name=sourcegraph-frontend-0"
Once the server is ready, navigate to the sourcegraph-frontend-0
hostname or IP address on port 80
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4