Skip to content

Instantly share code, notes, and snippets.

@guillaumesmo
Last active August 21, 2018 00:28
Show Gist options
  • Save guillaumesmo/229b5b29671336bdc867308b3947cdf2 to your computer and use it in GitHub Desktop.
Save guillaumesmo/229b5b29671336bdc867308b3947cdf2 to your computer and use it in GitHub Desktop.
Run public git repository in docker
#!/bin/bash
container=$(docker run -d -p 80:80 ynohat/git-http-backend)
docker exec ${container} sh -c "cd git && git init --bare $1.git && cd $1.git && git config http.receivepack true"
repo=$(curl -s https://$PWD_HOST_FQDN/sessions/$SESSION_ID | jq -r ".instances | to_entries[0].value | \"http://\" + .proxy_host + \"-80.direct.$PWD_HOST_FQDN/git/$1.git\"")
mkdir -p /root/htdocs/
echo "<h1>$1.git</h1>" >> /root/htdocs/index.html
echo "<h2>Push</h2>" >> /root/htdocs/index.html
echo "<pre>git remote add origin $repo</br>git push --set-upstream origin master</pre>" >> /root/htdocs/index.html
echo "<h2>Clone</h2>" >> /root/htdocs/index.html
echo "<pre>git clone $repo</pre>" >> /root/htdocs/index.html
docker run -d -p 8080:80 -v /root/htdocs:/usr/local/apache2/htdocs httpd:alpine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment