Customizing the gitlab home page

The customization of the Gitlab home page is a proprietary extension that is not available in the Free Software version. When running Gitlab from docker containers, the home page template needs to be moved to a file that won’t go away with the container:

$ layouts=/home/git/gitlab/app/views/layouts/
$ docker exec gitlab mkdir -p /home/git/data/$layouts
$ docker exec gitlab mv $layouts/devise.html.haml /home/git/data/$layouts
$ docker exec gitlab ln -s /home/git/data/$layouts/devise.html.haml \

The template can now be modifed in /opt/gitlab/data/home/git/gitlab/app/views/layouts/ from the host running the container. It is a HAML template which can have raw HTML as long as proper indentation is respected.

If the template contains a bug, the error message can be displayed with

$ docker exec gitlab tail -f /home/git/gitlab/log/production.log
Started GET "/users/sign_in" for at 2014-12-24 11:52:41 +0000
Processing by SessionsController#new as HTML
Completed 500 Internal Server Error in 12ms
ActionView::Template::Error (Inconsistent indentation:
  15 spaces used for indentation,
  but the rest of the document was indented using 2 spaces.):
    13:         .row
    14:           .col-md-7.brand-holder
    15:             %p.lead
    16:                working on Ceph
    17:           .col-md-5
    18:             = yield
    19:     %hr
  app/controllers/sessions_controller.rb:25:in `new'

The gitlab process must be restarted to ensure the template result is not cached:

$ docker exec gitlab /etc/init.d/gitlab restart
Shutting down both Unicorn and Sidekiq^C
Session terminated, terminating shell... ...terminated.

Although the above never completes, the process is indeed restarted and it can be terminated with Control-C after a few seconds.
The symbolic link needs to be restored each time the container is run with

$ layouts=/home/git/gitlab/app/views/layouts/
$ docker exec gitlab ln -sf /home/git/data/$layouts/devise.html.haml $layouts/devise.html.haml

One Reply to “Customizing the gitlab home page”

Comments are closed.