Installing Sourcegraph on Alpine Linux Latest

Pre-requisites

Before we proceed with the installation of Sourcegraph, the following must be met:

Step 1: Update the System

The first step is to update the system by running the following command:

sudo apk update && sudo apk upgrade

Step 2: Install Docker

Sourcegraph requires Docker to be installed on the machine. Run the following command to install Docker:

sudo apk add docker

Step 3: Start Docker

After installing Docker, start the Docker daemon by running the following command:

sudo rc-service docker start

Step 4: Install Docker Compose

Next, we need to install Docker Compose, a tool used for defining and running multi-container Docker applications. Run the following command:

sudo apk add docker-compose

Step 5: Clone the Sourcegraph Git Repository

Clone the Sourcegraph Git repository by running the following command:

git clone https://github.com/sourcegraph/deploy-sourcegraph.git

Step 6: Create Docker Volumes

Create the required Docker volumes by running the following commands:

sudo docker volume create grafana-storage
sudo docker volume create prometheus-storage
sudo docker volume create redis-storage
sudo docker volume create repo-updater-config
sudo docker volume create sourcegraph-frontend
sudo docker volume create sourcegraph-index
sudo docker volume create sourcegraph-postgres
sudo docker volume create sourcegraph-redis
sudo docker volume create symbols-cache

Step 7: Configure Sourcegraph

To configure Sourcegraph, run the following command in the directory where the repository was cloned:

sudo docker-compose run --rm src poweruser edit-config

This will open the Sourcegraph configuration file in a text editor. Make any changes you wish to make, save the file and exit the text editor.

Step 8: Start Sourcegraph

Finally, start Sourcegraph by running the following command:

sudo docker-compose up -d

This will start all the required Sourcegraph containers in detached mode.

Conclusion

Congratulations! You have successfully installed Sourcegraph on Alpine Linux Latest. You can now access Sourcegraph by navigating to the IP address or domain name of the machine on which it was installed on port 7080.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!