From c8a62b1c94678c6e140091bea5283f1fe5ef56b0 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Sat, 26 Apr 2014 16:52:58 +0530 Subject: [PATCH] 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 ``` --- Changelog.md | 1 + assets/init | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Changelog.md b/Changelog.md index 77ec8818..507dc38c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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. diff --git a/assets/init b/assets/init index a21f0674..16ed2a50 100755 --- a/assets/init +++ b/assets/init @@ -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