Skip to content

Commit

Permalink
How to configure local git server
Browse files Browse the repository at this point in the history
Using a local git server we can deploy ocm applications without network
access to github. This is useful for demos when the network is
unreliable, for example in a conference.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Jan 14, 2024
1 parent 71b6e0d commit 74c7dce
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
88 changes: 88 additions & 0 deletions test/gitlap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Setting up a local git server

## Initial setup

1. Install lighttpd

```
sudo dnf install lighttpd
```

1. Create the git repo

Create a directory where the git repositories will be served:

```
sudo mkdir /var/www/gitlap
cd /var/www/gitlap
sudo git clone --bare https://github.com/nirs/ocm-kubevirt-samples.git
```

Set git repo permissions so you can push changes, and the web server
can serve the repo.

```
sudo chown -R $USER:lighttpd /var/www/gitlap
```

1. Copy the vhost configuration

```
sudo cp gitlap.conf /etc/lighttpd/vhosts.d/
```

1. Uncomment the vhost include in /etc/lighttpd/lighttpd.conf

```
include conf_dir + "/vhosts.d/*.conf"
```

1. Enable and start the service

```
sudo systemctl enable --now lighttpd
```

1. Allow http access in the libvirt zone

```
sudo firewall-cmd --zone=libvirt --add-service=http --permanent
sudo firewall-cmd --reload
```

## Testing the server

1. Add entry in /etc/hosts for testing locally

```
192.168.122.1 host.minikube.internal
```

1. Check that git clone works

```
git clone http://host.minikube.internal/ocm-kubevirt-samples.git
rm -rf ocm-kubevirt-samples
```

1. Check git clone in a minikube cluster

```
minikube ssh -p dr1
git clone http://host.minikube.internal/ocm-kubevirt-samples.git
rm -rf ocm-kubevirt-samples
```

## Updating the git repo

1. Add a remote to your working repo

```
git remote add gitlap file:///var/www/gitlap/ocm-kubevirt-samples.git
```

1. Push changes to the remote

```
git push -f gitlap main
```
17 changes: 17 additions & 0 deletions test/gitlap/gitlap.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Minimal configuration for local git server for minikube clusters.
#
# For more options see:
# https://redmine.lighttpd.net/projects/lighttpd/wiki/How_to_set_up_a_git_server_over_http(s)

server.modules += ("mod_setenv", "mod_cgi", "mod_alias")

# `host.minikube.internal` is a special DNS name injected by minikube to all clusters.
# https://minikube.sigs.k8s.io/docs/handbook/host-access/
$HTTP["host"] == "host.minikube.internal" {
alias.url = ( "" => "/usr/libexec/git-core/git-http-backend" )
setenv.set-environment = (
"GIT_PROJECT_ROOT" => "/var/www/gitlap/",
"GIT_HTTP_EXPORT_ALL" => "1"
)
cgi.assign = ( "" => "" )
}

0 comments on commit 74c7dce

Please sign in to comment.