|
1 |
| -# go-code |
| 1 | +# go-git-dir |
2 | 2 |
|
| 3 | +This project was inspired by gitolite, but also includes a built-in ssh server |
| 4 | +and some additional flexability. It is not considered stable, but should be |
| 5 | +usable enough to experiment with. |
| 6 | + |
| 7 | +The main goal of this project is to enable simple git hosting when a full |
| 8 | +solution like Bitbucket, Github, Gitlab, Gitea, etc is not needed. It should |
| 9 | +require no additional resources, other than the directory it is pointed at, the |
| 10 | +running server, and a git installation. |
| 11 | + |
| 12 | +Thankfully because all the repos are simply stored as bare git repositories, it |
| 13 | +should be fairly simple to migrate to or from other git hosting solutions. |
| 14 | + |
| 15 | +## Requirements |
| 16 | + |
| 17 | +Build requirements: |
| 18 | + |
| 19 | +- Go 1.13 |
| 20 | +- libgit2 0.28 |
| 21 | + |
| 22 | +Runtime requirements: |
| 23 | + |
| 24 | +- libgit2 0.28 |
| 25 | +- git |
| 26 | + |
| 27 | +## Building |
| 28 | + |
| 29 | +From the root of the source tree, run: |
| 30 | + |
| 31 | +``` |
| 32 | +go build |
| 33 | +``` |
| 34 | + |
| 35 | +This will create a binary called go-git-dir. |
| 36 | + |
| 37 | +## Running |
| 38 | + |
| 39 | +### Server Config |
| 40 | + |
| 41 | +There are a number of environment variables which can be used to configure your |
| 42 | +go-git-dir instance. |
| 43 | + |
| 44 | +The following are required: |
| 45 | + |
| 46 | +- `GITDIR_BASE_DIR` - A directory to store all repositories in. This folder must |
| 47 | + exist when the service starts up. |
| 48 | + |
| 49 | +The following are optional: |
| 50 | + |
| 51 | +- `GITDIR_LOG_READABLE` - A true value if the log should be human readable |
| 52 | +- `GITDIR_LOG_DEBUG` - A true value if debug logging should be enabled |
| 53 | + |
| 54 | +### Runtime Config |
| 55 | + |
| 56 | +The runtime config is stored in the "admin" repository. It can be cloned and |
| 57 | +modified by any admin on the server. In it you can specify groups (groupings of |
| 58 | +users for config or convenience reasons), repos, and orgs (groupings of repos |
| 59 | +managed by a person). |
| 60 | + |
| 61 | +Additionally, there are a number of options that can be specified in this file |
| 62 | +which change the behavior of the server. |
| 63 | + |
| 64 | +- `user_repos` - allow users to have repos located at ~username/repo-name |
| 65 | + |
| 66 | +There are a number of additional options in the sample config but they have not |
| 67 | +been implemented yet. |
| 68 | + |
| 69 | +## Usage |
| 70 | + |
| 71 | +Simply run the built binary with `GITDIR_BASE_DIR` set and start using it! |
| 72 | + |
| 73 | +On first run, go-git-dir will push a commit to the admin repo with a sample |
| 74 | +config as well as generated server ssh keys. These can be updated at any time |
| 75 | +(even at runtime) but if the server restarts and the keys cannot be loaded, they |
| 76 | +will be re-generated. |
| 77 | + |
| 78 | +Note that you will need to manually clone the admin repository (at |
| 79 | +`$GITDIR_BASE_DIR/admin/admin`) to add a user as a .yml file in the users dir |
| 80 | +and define the admins group before things work as expected. |
| 81 | + |
| 82 | +Example user file: |
| 83 | + |
| 84 | +``` |
| 85 | +keys: |
| 86 | + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIIdmFwaB4lwmogg7ggFE8M45Zywx1W3T7dGktY563FM belak@laptop |
| 87 | +``` |
| 88 | + |
| 89 | +## Repo Creation |
| 90 | + |
| 91 | +Currently, if anyone has write access to a repo location, a repo will be |
| 92 | +auto-created on the first push there. |
0 commit comments