With the update to DSM7, Synology does not provide a GitLab package anymore. The best way to keep GitLab running is to run it in a Docker container.
Also, the latest GitLab version provided by Synology is 13.12.2. In order to keep the data the same, the "old" version has to be installed in the container first and then updated to a recent version.
In order to test the export of the GitLab data from the Synology NAS before upgrading to DSM7, the GitLab container is first installed and run on another Arch Linux PC.
ssh access to the Synology NAS is enabled.
Log in via SSH to your NAS. Run the following command to create a backup:
sudo docker exec -u git -i synology_gitlab /home/git/gitlab/bin/rake gitlab:backup:create --trace
The backup file is in the directory /volume1/docker/gitlab/gitlab/backups. Copy the backup file to your PC or to a folder on your volume on your NAS where you can access it later.
Hint: It might be necessary to grant read permissions on the file for other users.
sudo chmod o+r volume1/docker/gitlab/gitlab/backups/?????_13.12.2_gitlab_backup.tar
Copy the environment keys; they will be needed to restore the backup.
GITLAB_SECRETS_OTP_KEY_BASE
GITLAB_SECRETS_DB_KEY_BASE
GITLAB_SECRETS_SECRET_KEY_BASE
Hint: You can get the environment variables via the terminal.
sudo docker ps
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# xxxxxxxxxxx synology/gitlab:13.12.2-saml-patched "/sbin/entrypoint.sh…" 15 months ago Up 16 minutes 22/tcp, 0.0.0.0:30000->80/tcp, 0.0.0.0:30001->443/tcp synology_gitlab
sudo docker exec xxxxxxxxxxx cat /proc/1/environ | tr '\0' '\n'
Install docker
pacman -S docker
Install docker-compose
pacman -S docker-compose
Start docker deamon
sudo systemctl start docker.service
For xxxxxxxxxxxxxxxxxxxxxxxx insert the corresponding key from the Synology GitLab docker environment.
docker-compose.yml
services:
gitlab:
image: gitlab/gitlab-ce:13.12.2-ce.0
container_name: gitlab
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_SECRETS_SECRET_KEY_BASE: "xxxxxxxxxxxxxxxxxxxxxxxx"
GITLAB_SECRETS_DB_KEY_BASE: "xxxxxxxxxxxxxxxxxxxxxxxx"
GITLAB_SECRETS_OTP_KEY_BASE: "xxxxxxxxxxxxxxxxxxxxxxxx"
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.example.com:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2424
ports:
- '8929:8929'
- '443:443'
- '2424:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab'
- '/srv/gitlab/logs:/var/log/gitlab'
- '/srv/gitlab/data:/var/opt/gitlab'
shm_size: '256m'
Ensure that you do not overwrite existing data!
The folders must be created according to the folders defined in the docker-compose file.
sudo mkdir /srv/gitlab/config
sudo mkdir /srv/gitlab/logs
sudo mkdir /srv/gitlab/data
sudo mkdir /srv/gitlab/data/backups
# Run in the folder where the docker-compose.yml file was created.
sudo docker compose up -d
Verify that the container is running by opening GitLab's web interface (http://127.0.0.1:8929).
Copy the backup ?????_13.12.2_gitlab_backup.tar to folder /srv/gitlab/backups.
Enter into bash mode on the gitlab docker
sudo docker exec -ti <container_id> bash
Restore the backup
NOTE: The backup file name will look like this: 1770492387_2022_06_11_13.12.2_gitlab_backup.tar. For the restore command, the ending _gitlab_backup.tar has to be removed.
gitlab-backup restore BACKUP=1770492387_2026_02_07_13.12.2
NOTE: There are several questions that have to be answered with yes. Also, for me, several errors have been displayed; all content was available after the restore.
In order to update GitLab to a recent version, a stepwise update procedure is suggested.
The update can be performed by stopping the Docker container, adjusting the version of the GitLab image in the docker-compose.yml file, and then starting the container again.
Please ensure to verify that the update was successful after every step. To be safe, further backups of the data can be done in between.
# change in docker-compose.yml
# image: gitlab/gitlab-ce:13.12.2-ce.0 -> image: gitlab/gitlab-ce:14.0.2-ce.0
# stop docker
sudo docker stop <container-id>
# start docker
sudo docker compose up -d
Here is a suggested upgrade pattern:
-> 13.12.2 -> 14.0.2 > 14.1.0 -> 14.1.3 -> 14.2.1 -> 14.2.2 -> 14.2.4 -> 14.3.1 -> 14.4.0 -> 14.5.0 -> 14.6.1 -> 14.7.0 -> 14.8.0 -> 14.9.0 -> 14.9.3 -> 14.10.0 -> 14.10.3 -> 15.0.0 -> 15.1.0 -> 15.2.2 -> 15.2.4 -> 15.3.3 -> 15.4.0
NOTE: The suggested upgrade path can be viewed on the following website by specifying the current and target version: https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/
Ensure to update/upgrade the container until the version is reached that will be running under DSM7.
NOTE: In order to use Docker Compose, Synology Container Manager must be used instead of Docker. Container Manager replaces Docker and is available on DSM 7.2 and higher. From 7.1 to 7.2 for my DS918+, the update has to be performed manually.
The update packages can be downloaded from the Synology website: https://www.synology.com/en-global/support/download/DS918+?version=7.3#system
Create a backup of from you updated GitLab docker repro.
sudo docker exec -ti <container_id> bash
gitlab-backup create
exit
The backup can now be found in following folder: /srv/gitlab/data/backups
Log in via SSH to your NAS. Run the following commands to create the folders for the GitLab Docker container or create the folders in Filestation.
mkdir /volume1/docker/gitlab
mkdir /volume1/docker/gitlab/config
mkdir /volume1/docker/gitlab/data
mkdir /volume1/docker/gitlab/data/backups
mkdir /volume1/docker/gitlab/logs
Prepare the docker-compose.yml file on oyur computer, e.g.,
NOTE: Same GitLab version has to be installed as the version the backup was created with.
For xxxxxxxxxxxxxxxxxxxxxxxx insert the corresponding key from the former Synology GitLab docker environment.
services:
gitlab:
image: gitlab/gitlab-ce:15.4.0-ce.0
container_name: gitlab
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_SECRETS_SECRET_KEY_BASE: "xxxxxxxxxxxxxxxxxxxxxxxx"
GITLAB_SECRETS_DB_KEY_BASE: "xxxxxxxxxxxxxxxxxxxxxxxx"
GITLAB_SECRETS_OTP_KEY_BASE: "xxxxxxxxxxxxxxxxxxxxxxxx"
# use HTTP for internal communication between WebStation and Docker
# therfore, different external and internal ports are used.
# Web Station will be setup to act as a reverse proxy and
# provide external access via HTTPS
GITLAB_OMNIBUS_CONFIG: |
letsencrypt['enable'] = false
external_url 'https://mydomain.de:30001'
gitlab_rails['gitlab_shell_ssh_port'] = 2424
nginx['listen_https'] = false
nginx['listen_port'] = 8929
ports:
# HOST_PORT:CONTAINER_PORT
- '8929:8929'
- '30002:2424'
volumes:
- '/volume1/docker/gitlab/config:/etc/gitlab'
- '/volume1/docker/gitlab/logs:/var/log/gitlab'
- '/volume1/docker/gitlab/data:/var/opt/gitlab'
shm_size: '256m'
Copy the prepared docker-compose.yml file to /volume1/docker/gitlab/
Copy the GitLab backup created in the GitLab backup folder (srv/gitlab/data/backups) to the NAS (/volume1/docker/gitlab/data/backups).
Open the container manager and create a new project. Select the created docker base folder (/Volume1/docker/docker).
The file is now opened in an editor to verify its content; click next to continue.
For now skip the setup of the WebStation and continue with the creation and start of the container.
Once your container has started, navigate to the "Container" section of Container Manager, right-click on the "gitlab" container, and choose "Details." Note down the IP address listed in the Network section.
Open "Control Panel" on your Synology NAS, select "Security" and navigate to "Firewall". Click "Edit Rules" and add the following firewall rules.
GitLab can now be accessed via HTTP on port 8929 on your NAS. NOTE: This connection is not encrypted and shall only be used in a secure network!
For secure access via HTTPS, WebStation can be used. Therefore, enable the WebPortal settings for the 'gitlab' project in the container manager. Select the port defined in the Docker file (in this example, 8929) and HTTP for the internal communication.
Then, choose a port-based server portal in the Web Station dialog, enable HTTPS, and and use the port defined in the external_url so that it can be used to access GitLab using the certificate installed in the Web Station.
Log in via SSH to your NAS.
Open a bash in your GitLab instance.
NOTE: The backup file name will look like this: 1770492387_2022_06_11_15.4.0_gitlab_backup.tar. For the restore command, the ending _gitlab_backup.tar has to be removed.
sudo docker exec -u git -ti <container-id> bash
gitlab-backup restore BACKUP=1770492387_2022_06_11_15.4.0
NOTE: Due to the low performance of the NAS, I run into timeout error messages when restoring the backup. This could be solved by adjusting the following values in the gitlab/config/gitlab.rb configuration file: