fix git over ssh when the default http/https ports are not used.

Internally the SSH and the http/https servers always bind to ports 22 and
80/443 respectively. If the GITLAB_PORT variable is set to any other
port, then cloning over SSH would not work.

This is because internally gitlab-shell tries to communicate with the
gitlab server over http interface. In gitlab-shell configured with
the GITLAB_PORT value the conmmunication will effective fail and thereby
the cloning operation would return an error.

To fix this, we make gitlab-shell communicate with the http server
directly with the default http/https ports since this is all internal.

Prior to this update, cloning repositories over ssh protocol would not
work when the container is started in the following way:

```bash
docker run -i -t --rm \
  -p 8888:80 -p 2222:22 \
  -e "GITLAB_PORT=8888" -e "GITLAB_SHELL_SSH_PORT=2222" \
  sameersbn/gitlab
```
This commit is contained in:
Sameer Naik 2014-04-26 16:52:58 +05:30
parent 96d975d9f4
commit c8a62b1c94
2 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,7 @@
# Changelog
**latest**
- fix git over ssh when the default http/https ports are not used.
- compile the assets only if it does not exist or if the gitlab version has changed.
- upgrade gitlab-shell to version 1.9.4
- cache compiled assets to boost application startup.

View File

@ -238,6 +238,12 @@ sudo -u git -H sed 's,{{GITLAB_URL}},'"${GITLAB_URL}"',' -i /home/git/gitlab-she
sudo -u git -H sed 's/{{REDIS_HOST}}/'"${REDIS_HOST}"'/' -i /home/git/gitlab-shell/config.yml
sudo -u git -H sed 's/{{REDIS_PORT}}/'"${REDIS_PORT}"'/' -i /home/git/gitlab-shell/config.yml
# hack: make git over ssh work when the default http/https ports are not used.
case "${GITLAB_HTTPS}" in
true) sed -i 's,#{config.gitlab_url}/api/v3/internal,https://localhost/api/v3/internal,' -i /home/git/gitlab-shell/lib/gitlab_net.rb ;;
*) sed -i 's,#{config.gitlab_url}/api/v3/internal,http://localhost/api/v3/internal,' -i /home/git/gitlab-shell/lib/gitlab_net.rb ;;
esac
# configure unicorn workers
sed 's/{{UNICORN_WORKERS}}/'"${UNICORN_WORKERS}"'/' -i /home/git/gitlab/config/unicorn.rb