How to Install Sourcegraph on Void Linux
Sourcegraph is a code search and intelligence tool that helps developers search, navigate, and understand code repositories. This tutorial will guide you through the process of installing Sourcegraph on a Void Linux system.
Prerequisites
Before starting, make sure that your system has the following prerequisites:
- A running Void Linux installation
- Root access or the ability to use
sudo - A working internet connection
Step 1: Install Docker
Sourcegraph requires Docker to run, so the first step is to install Docker on your system. Run the following command to install Docker:
sudo xbps-install -S docker
Once Docker is installed, start the Docker daemon by running:
sudo systemctl start docker
You can check that Docker is running by running:
sudo docker ps
This should give you a list of running Docker containers.
Step 2: Download and Run Sourcegraph
The next step is to download and run Sourcegraph using Docker. Run the following command to download and start the Sourcegraph container:
sudo docker run --publish 7080:7080 --publish 127.0.0.1:3370:3370 --rm --volume ~/.sourcegraph/config:/etc/sourcegraph --volume ~/.sourcegraph/data:/var/opt/sourcegraph sourcegraph/server:3.30.1
This command will download the Sourcegraph image and start a container with the following options:
--publish 7080:7080: map the container's port 7080 to the host's port 7080.--publish 127.0.0.1:3370:3370: map the container's port 3370 to the host's port 3370 for internal communication.--rm: remove the container when it exits.--volume ~/.sourcegraph/config:/etc/sourcegraph: mount the host's~/.sourcegraph/configdirectory to the container's/etc/sourcegraphdirectory.--volume ~/.sourcegraph/data:/var/opt/sourcegraph: mount the host's~/.sourcegraph/datadirectory to the container's/var/opt/sourcegraphdirectory.sourcegraph/server:3.30.1: the image to use.
Note that the sourcegraph/server:3.30.1 image tag may be different depending on the latest version available at the time of installation.
After running this command, you should see logs from the Sourcegraph server:
...
> [email protected] start /usr/local/src/sourcegraph
> node ./sbin/sourcegraph.js .
info: Frontend URL: http://localhost:7080/
info: Docker images:
info: debian:stretch-20190812-slim
info: golang:1.13.8-alpine
info: postgres:10.11
info: sourcegraph/ignite:20191204
info: sourcegraph/server:3.30.1
info: Postgres is at 127.0.0.1:5432
info: Access Sourcegraph at http://localhost:7080/
This means that Sourcegraph is now running.
Step 3: Access Sourcegraph
You can now access Sourcegraph by opening a web browser and navigating to http://localhost:7080/. You should see the Sourcegraph homepage:

Conclusion
Congratulations! You have successfully installed Sourcegraph on your Void Linux system. You can now use Sourcegraph to search, navigate, and understand code repositories.