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.
Before we can install GitLab on a DiskStation, we need to make some preparations:
- Install the Docker package from the Synology Package Center.
- Create a Shared Folder for GitLab. For this article, I assume that the Shared Folder is named gitlab and is created on the first volume, so its path on the filesystem will be /volume1/gitlab.
- Activate DSM SSH access. You can also activate Public Key Authentication for DiskStation SSH access following this tutorial.
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.
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.
Before we click on Next, we have to do some configuration in the Advanced Settings dialog.
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 volume mounting into the previously created shared directory.
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.
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://<NAS IP>:8080.
On this screen, you can set the password for the root user of GitLab.
Before your GitLab instance is ready for usage, we have to finalize the configuration. Use the DSM Docker application for shutting down the 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.
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.
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.
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.