Gitlab on a Diskstation

Gitlab on a Diskstation

29.12.2019

Sometimes, regardless of the possibilities offered by "the cloud", you want to host important services yourself. For me as a software and DevOp engineer, this applies to my source code. For this reason, I host my GitLab instance myself. Since the GitLab package for DSM provided by Synology is outdated, I will explain here how to install the latest version of GitLab on a DiskStation using Docker.

Preparations

Before we can install GitLab on a DiskStation, we need to make some preparations:

Setup GitLab on a DiskStation

Now we are going to install GitLab. To do so, we need to download the latest docker image of GitLab first. Open the Docker App in DSM, select Registry in the left menu and download the latest gitlab/gitlab-ce image.

Download GitLab image from Docker Hub

You can watch the download progress in the menu on the left in Image. As soon as the download is complete, a new container can be created with Launch in the upper left corner.

Launch GitLab container

Before we click on Next, we have to do some configuration in the Advanced Settings dialog.

Volumes

We need to persist three directories of GitLab:

  • /etc/gitlab - configuration directory
  • /var/opt/gitlab - user-generated content (repositories, database, ...)
  • /var/log/gitlab - logfiles

We do this by defining directory volumes. This is done by mapping subdirectories of the previously created shared directory into the container by defining a mount path.

Configure GitLab volumes

Port Settings

To allow access to the GitLab instance from outside, we need to define port bindings. These port bindings will forward DiskStation host ports to the GitLab Docker container.

Configure GitLab port bindings

After applying all changes and starting the container, it will take a couple of minutes for GitLab to bootstrap the instance. After a while, you should be able to access your new GitLab instance at http://:8080.

Access GitLab instance

On this screen, you can set the password for the root user of GitLab.

Final Configuration

Before your GitLab instance is ready for usage, we have to finalize the configuration. Use the DSM Docker application for shutting down the container.

Shut down GitLab container

When the container is off, connect to your DiskStation via SSH. Open the GitLab configuration file /volume1/gitlab/config/gitlab.rb and adjust (at least) the following configuration:

  • external_url - Set to the URL you want to use for accessing GitLab.
  • gitlab_rails['gitlab_shell_ssh_port'] = 7999 - Use port 7999 for Git via SSH, since port 22 is already taken by your DiskStation.

Further Considerations

External Access

You have to decide how to configure external access to your GitLab instance. The simplest option might be to configure a port forwarding from your router to the GitLab ports on your DiskStation. Another possibility is to use DSM's reverse proxy.

HTTPS Encryption

Both, DSM and GitLab have built-in support for requesting LetsEncrypt certificates for HTTPS. If you're not using DSM's reverse proxy, you should configure LetsEncrypt in your gitlab.rb configuration.

If you're using the DSM reverse proxy, you can still use GitLab's capabilities for getting LetsEncrypt certificates or configure HTTPS offloading (the reverse proxy terminates the HTTPS connection and forwards requests internally using HTTP) and use DSM's capabilities for getting LetsEncrypt certificates. When configuring the hosts, please be sure to enable Websocket Support.

The End

After you finished configuration, use the DSM Docker GUI to start your GitLab container again.

Congratulation! Your GitLab on a DiskStation is now up and running!

For questions, don't hesitate to leave a comment below. For personal support, you can also contact me directly.