In this post, I'll talk about how we can setup CGit within a docker-compose setup. We'll be using the [ClearLinux CGit](https://hub.docker.com/r/clearlinux/cgit) container.
## Configuring Apache Webserver
Within the CGit container, an apache webserver is setup to execute the CGit CGI scripts. This configuration is very similar to the [default one](https://github.com/clearlinux/dockerfiles/blob/256680f7c6be8423081e67153de0bff1206f6b63/cgit/httpd-cgit.conf) provided by ClearLinux. However, the default holds your repositories in the `/cgit` subfolder as I wanted it on the root `/` folder.
Now to configure `cgit` itself, we need to create a file called `cgitrc`. Order matters in the declarations, and from what I can gather you should have your `scan-path` near the end of the file.
To enable cloning and have it discoverable:
```ini
enable-http-clone=1
clone-prefix=https://URL/TO/WEBSITE
```
To download snapsots of the references
```ini
snapshots=tar.gz zip
```
To enable the git config to override the owner and description fields
```ini
enable-git-config=1
```
Cache up to 1000 output entries
```ini
cache-size=1000
```
Root Page configuration
```ini
root-title=Brandon Rozek's Repositories
root-desc=
repository-sort=age
# Start all URLs from the root directory
virtual-root=/
```
Server the appropriate mime-types of certain files
I prefer using `docker-compose` to help manage all my containers. The first two volumes map the configuration files we created and the last volume holds our repositories.
Within `/var/www/cgit`, start cloning your repositories:
```bash
git clone --bare REPO_URL
```
If you enabled gitinfo then for each repository you can run `git config -e` and add the following
```ini
[gitweb]
owner = Name <Email>
description = Insert your project description here
```
### Aside: Reverse Proxy
In my setup, I have an `nginx` container that handles all of the traffic. Therefore, I don't have users enter to the cgit container directly. I handle this by adding the following reverse proxy configuration.