Skip to content

sourcegraph/sourcegraph-git-mirror-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WIP

Sourcegraph with a git mirror

This project is an example of how to set up Sourcegraph with a git mirror between it and your code host.

Overview

This project uses RalfJung/git-mirror as the mirroring system. It uses gitolite as the mirror. Docker compose is used to run Sourcegraph and Gitolite. Once it's up and running, you'll be able to add your code host as an external service to Sourcegraph. We'll cover the configuration needed to clone through the mirror rather than the code host.

Setup

To start, run the project with the following command:

SSH_KEY="$(cat ~/.ssh/id_rsa.pub)" SSH_KEY_NAME="$(whoami)" make run

Gitolite setup

Once gitolite is running, we'll need to give Sourcegraph permission to access it.

First, we need to get a public ssh key for Sourcegraph. Start by accessing the Sourcegraph Server:

docker exec -it sourcegraph /bin/bash

Next, navigate to the root user's ssh directory and create a key.

cd ~/.ssh
ssh-keygen # ... follow prompts to create the key

# Close the connection
exit

Once the key is created, copy that to your local machine.

docker cp sourcegraph:/root/.ssh/id_rsa.pub /tmp/id_rsa.pub

Next, we'll clone the gitolite-admin repository. To do this, we first must tell git clone what port gitolite is listening on. In your ~/.ssh/config, add the following entry:

Host localhost
  User git
  Port 2222

Now, clone the repository:

git clone git@localhost:gitolite-admin
cd gitolite-admin

Once inside the admin repository, all we need to do is add the public key we created to the keydir and push this change back to the origin.

cp /tmp/id_rsa.pub ./keydir
git add .
git commit -m "add sourcegraph public key"
git push origin

About

An example repository showing how to run Sourcegraph with a git mirror

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published