Giter Club home page Giter Club logo

synology-gitlab-ce's Introduction

synology-gitlab-ce

This is a docker based GitLab CE package for Synology NAS server using the original gitlab/gitlab-ce image from hub.docker.com. The goal of this project is to lower the entry barrier for new GitLab users and give experienced users a little comfort in maintaining their GitLab installation.

Everything this package does, can be also done manually over the Synology Docker NAS Application.

Please note that I can not give you support for GitLab itself, this project covers only the Synology installation/update routines. If you need GitLab Support you might get it here https://forum.gitlab.com.

Download SPK:

You can download the SPK file in the Releases section.

Hardware Requirements:

  • 1 CPU core ( 2 cores is recommended )
  • 2 GB RAM ( 4GB RAM is recommended )
  • DSM 6.0 and DSM 7.0 compatible

Classic:

very simplistic package, installation and basic configuration over DSM, no ssh or root privileges required. But this comes with a tradeoff, container configuration (ports,volumes,etc.) after the installation is not possible. This is because of the DSM no root privilege policy. However the settings can be changed but only by uninstalling and reinstalling the package again. During uninstallation of this package all data will be deleted by DSM. Please do not forget to backup before. Upgrade to Advanced is possible, but be careful and backup, backup, backup!

WARNING: All gitlab data will be deleted on uninstall! Backup berfore uninstalling!

Classic installer image

Advanced:

this approach bypass the root privileges limitation of the DSM by running the setup over ssh. The final container runs exactly with the same privileges and setup as the classic non-root approach but you need to execute the installer as root to get the setup done. This is a more flexible variant because this way you get the full access to the container settings and an update simply exports you current container configuration and imports it again with a modified GitLab image version. This way all your configuration remains the same and you can downgrade and upgrade as you like. As far as GitLab supports the downgrade with your specific dataset. The ssh installer/updater gives you also the ability to run multiple gitlab container instances with different container/versions and different data shares. You can test your upgrades and migrations without any risk and downtime.

Advanced installer DSM image

Install Advanced Instance Advanced installer install image

Update Advanced Instance Advanced installer update image

Multiple Advanced Instances Advanced multiple instances

Overview Advanced vs Classic

Feature Advanced Classic
DSM only install
requires ssh for install
requires root privileges
gitlab can be upgraded
gitlab can be downgraded
multiple parallel gitlab instances
start/stop over Synology Package Manager
start/stop over Synology Docker app
exposed gitlab configuration and data
container settings accessible
access to container environment variables
keeps container settings (ports, volumes, links) on updates
GitLab files (data, config) remains on package uninstall

Build instructions

Clone this repository and execute the build.sh shell script within your terminal application. This can be done on any linux and should also work on WSL. Except "jq" there are no special packages/binaries required.

# Syntax: build.sh [options]
# options:
#   --version - GitLab CE version e.g. 13.4.3-ce.0, 
#               when no version given, a selection list of the latest
#               available versions is shown
#   --type    - package type (classic|advanced) - default: classic
#   --dsm     - target DSM version (6|7) - default: 7

./build.sh --version=13.4.3-ce.0 --dsm=7 --type=classic

GitLab Upgrade Path

It's highly recommended to follow the upgrade path especially if you update to another major release. You can check the recommended upgrade path here. Please take your time and make backups in between updates. Be Patient during update, this may take up to 30 minutes. You can see the progress in the Docker app in the Details->Protocol tab. Once no new lines occur in the protocol and the container consume over 4GB RAM, the update should be complete.

see: https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/?edition=ce

Install/Update Classic Instance

Download the desired SPK Version and install it. If you have a previous version of Gitlab installed, just install the new SPK over the existing Gitlab installation. This will automatically update the existing installation.

Install Advanced Instance

# Location: /var/packages/synology-gitlab-ce/scripts
# Syntax: gitlab <action> <container> [options]
# arguments:
#   action       - install or update
#   container    - container name
# options:
#   --version    - GitLab CE version e.g. 13.4.3-ce.0
#   --share      - destination folder which will contain shared gitlab files
#   --port-ssh   - ssh host port
#   --port-http  - http host port
#   --port-https - https host port

cd /var/packages/synology-gitlab-ce/scripts && \
sudo sh gitlab install synology-gitlab-ce \
--version=13.4.3-ce.0 \
--share=synology-gitlab-ce \
--port-ssh=30022 \
--port-http=30080 \
--port-https=30443

Update Advanced Instance

cd /var/packages/synology-gitlab-ce/scripts && \
sudo sh gitlab update synology-gitlab-ce --version=13.4.5-ce.0

Connect into container

If you want to bash into your gitlab container you can do this with this command

sudo docker exec -it "<gitlab-container-name>" bash 

Reset Password

If you forgot your password or after the install GitLab does not redirect you to the password reset form. You can reset your password from the command line. On a fresh install the main user is 'root'. See also the documentation.

sudo docker exec -it "<gitlab-container-name>" bash -c "gitlab-rake 'gitlab:password:reset'" 

GitLab Configuration

For configuration of the omnibus based GitLab image please refer to this documentation https://docs.gitlab.com/omnibus/settings.

# after any change to the gitlab configuration you need to reconfigure 
# gitlab and restart the services, which can be done with this two 
# commands from your ssh terminal   

sudo docker exec -t "<gitlab-container-name>" bash -c "gitlab-ctl reconfigure"
sudo docker exec -t "<gitlab-container-name>" bash -c "gitlab-ctl restart"

SSL (self-signed) helper

This helper installs for you a self-signed SSL certificate to your gitlab container and configures your gitlab to use this. Please do not use this for public accessible instances, this approach only makes sense if you run your GitLab private on your LAN and you're lazy to do a proper SSL certificate and install it. In any other case i recommend you to use the GitLab Let's Encrypt integration.

# Location: /var/packages/synology-gitlab-ce/scripts
# Syntax: gitlab-self-signed-cert <action> [<container>] [options]
# arguments:
#   action       - install
#   container    - container name
# options:
#   --hostname   - gitlab hostname - default: xpenology
#   --https-port - https port - default: 80443

cd /var/packages/synology-gitlab-ce/scripts && \
sudo sh gitlab-self-signed-cert install synology-gitlab-ce \
  --hostname=xpenology --https-port=80443

Shortcut helper

If your GitLab shortcut in your DSM got broken or points to the wrong container (port) you can fix it with this helper anytime.

# Location: /var/packages/synology-gitlab-ce/scripts
# Syntax: gitlab-link-fix [options]
# options:
#   --protocol   - protocol http|https - default: http
#   --port       - port - default: 30080

cd /var/packages/synology-gitlab-ce/scripts && \
sudo sh gitlab-link-fix --protocol=https --port=30443

Backup

Please refer to this documentation here. It is not recommended to store data backups in the same location as your config/credentials backup. Because of this, the backup process is split into two steps, the config backup and the data backup.

# backup gitlab configuration
# you will find you backups in this folder 
# /docker/<gitlab-container-share>/config/config_backup 
sudo docker exec -it "<gitlab-container-name>" gitlab-ctl backup-etc

# backup gitlab data (repositories and content)
# you will find you backups in this folder 
# /docker/<gitlab-container-share>/data/backups
sudo docker exec -it "<gitlab-container-name>" gitlab-backup 

Restore

Please refer to the GitLab documentation here.

# restore gitlab configuration
# unzip your configuration backup to the config folder overwriting existing files 
# config folder: /docker/<gitlab-container-share>/config
# after that you can continue with the data restore

# restore gitlab data
# copy your data backup to the data/backups folder 
# /docker/<gitlab-container-share>/data/backups
sudo docker exec -it "<gitlab-container-name>" gitlab-ctl stop puma   
sudo docker exec -it "<gitlab-container-name>" gitlab-ctl stop sidekiq
# verify puma & sidekiq are down
sudo docker exec -it "<gitlab-container-name>" gitlab-ctl status    
# fix permissions
sudo docker exec -it "<gitlab-container-name>" chown git:git /var/opt/gitlab/backups/1647529095_2022_03_17_13.4.3_gitlab_backup.tar
# restore, please omit the "_gitlab_backup.tar" from the backup archive name
sudo docker exec -it "<gitlab-container-name>" gitlab-backup restore BACKUP=1647529095_2022_03_17_13.4.3

# restart the GitLab container
sudo docker restart "<gitlab-container-name>"

# check GitLab
sudo docker exec -it "<gitlab-container-name>" gitlab-rake gitlab:check SANITIZE=true

Set external URL

The Problem here is that the nginx within the container is running on port 80 and this is not exposeable to your DSM without big hassle. If you are not familiar with vi editor, please see: How to edit with vi eidtor.

# connect to gitlab container
sudo docker exec -it "<gitlab-container-name>" bash 

# edit config file 
vi /etc/gitlab/gitlab.rb
  # search for '# external_url 'GENERATED_EXTERNAL_URL'
  external_url 'http://<external_url>:<external_port>'
  # the port in the external_url force nginx to run on another port, we have to set it back to 80/443 because of our 
  # container port mapping
  # search for '# nginx['listen_port'] = nil'
  nginx['listen_port'] = 80

Create GitLab Runner

Migration can only be done within the same GitLab version. Its is basically a backup from synology-gitlab package and restore to the synology-gitlab-ce package.

# 1) ssh into your synology and run 
sudo ln -s /var/run/docker.sock /volume1/docker/docker.sock
# 2) download tools/gitlab-runner.json and upload to your synology on any folder over DSM (fil should be accessible over DSM)
# 3) Go to your Docker App Settings->Import and select the gitlab-runner.json and start the import
# 4) bash into your gitlab-runner container
docker exec -it <gitlab-runner-name> bash
# 5) execute the registration command you get from here () http://<external_url>:<external_port>/admin/runners/new
gitlab-runner register  --url http://<external_url>:<external_port>  --token <token>

Migration from synology-gitlab package

Migration can only be done within the same GitLab version. Its is basically a backup from synology-gitlab package and restore to the synology-gitlab-ce package.

# backup config 
# @todo: not found a automated way yet
# here is the config located but its structure differs from the omnibus package, need 
# review and testing. For now, you can look up needed configuration and transfer it 
# manually to your new synology-gitlab-ce instance
sudo docker exec -w "/home/git/gitlab/config" -it synology_gitlab bash

# backup data
sudo docker exec -it synology_gitlab bash -c "sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production CRON=1"

# The synology-gitlab psql user differs from the synology-gitlab-ce so we need to 
# modify the database dump. Simply replace the "gitlab_user" with "gitlab". 
# The tools/fix_synology_gitlab_backup does that for you. 
# Syntax: fix_synology_gitlab_backup <file>
# arguments:
#   file    - path to your gitlab_backup.tar file

./tools/fix_synology_gitlab_backup 1647548012_2022_03_17_13.9.3_gitlab_backup.tar

# you will get a 1647548012_2022_03_17_13.9.3_gitlab_backup.tar.new file as output which 
# is ready for restore. Now you can process with the regular restore procedure above, 
# please do not forget to remove the ".new" suffix from file.

# NOTE: if you get following errors, they seems to be common. Despite the errors the 
# restore seems to work, further investigation needed. 
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/266988
#
# Restoring PostgreSQL database gitlabhq_production ... ERROR:  must be owner of extension pg_trgm
# ERROR:  must be owner of extension btree_gist
# ERROR:  must be owner of extension btree_gist
# ERROR:  must be owner of extension pg_trgm
#
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/266988#note_430408658
# Regarding to this post is everything fine as far as the restore doesn't break.
# Quote: "We ignore 'does not exist' and 'must be owner' of errors"

synology-gitlab-ce's People

Contributors

caco3 avatar gcutrini avatar jboxberger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

synology-gitlab-ce's Issues

Unclear Instructions

I'm looking at this and not really getting how to use it.

I'm looking to install GitLab on a new diskstation. I had been using the old Synology package on a 918+ but the lack of attention from Synology is a shame.

The synology-gitlab-ce-15.1.2-dsm7-advanced.spk. What do I do with this file? It's not mentioned in your instructions at all. Is this a package that needs installing on the NAS?

Your commands like 'cd /var/packages/synology-gitlab-ce ... ' Are these commands being run on the Synology?

Have to admit this is all a little confusing.

Migration from very old official synology package (11.8)

i'm trying for days to update an old gitlab installation, so i can switch to this repo and upgrade to dsm7. For this I'm trying to arrive at version 12.10.6, the lowest version available here.

Unfortunately updating the official synology package to 12.10.6 doesn't work, as it requires a postresql update from 10 to 11 and the bionic release of postresql has been moved to an archive, and even if i change this in the sources.list file the upgrade will fail, as it will download a new image and create a new container reversing any changes.

I successfully upgraded up until 12.4.2 using the predecessor of this package from @jboxberger (non ce version), 12.9 i can run, see projects, commits, etc. but it won't load actual blob data. Upgrade to 12.10.6 fails.

so i tried to build this repo for 12.0.3 or 12.4.2, which installs fine, but the container stops after a few minutes
grafik

i have also tried installing 12.10.6 from this repo and downgrade to 12.4.2 or 12.0.3, same errors....

It's not a huge gitlab server, I am ready to export groups and projects and import in another instance, but for this i would have to come as close as 2 minor versions to 12.10.6, which i simply can't manage to do.

i don't know much about any of this, any help would be greatly appreciated!

Works succesfully, including migration to 16.0.1

First of all: thanks a lot for creating this package. This is really cool!

Being not a typical user of docker on Synology or Gitlab, I managed with a bit of experimentation to set it up successfully. Some issues prompted me to redo the stuff, even though reinstallation was not really necessary (this might help in the readme:

  • the time until things are stable (and a connection is possible may take several minutes after the installation is complete. During this no connection is possible or a error message is shown.
  • The current package gives 15.1.2, but one can successfully upgrade to: 15.11.6 and then to 16.0.1 (the step through 15.11.6 is recommended and it is necessary to cross-check that migrations in the admin are successful (may require to restart failed migrations).
  • a direct import from the NAS git server does not seem to possible (highly annoying). As this only supports ssh and gitlab only supports git, http, and https protocols. The correct way is then to locally create a cloned repo and then manipulate the origins and push. (actually I am not sure, why it works so easily without any security questions, but it does.)

If there is interest, I can also create more detailed descriptions and provide a pull request for the wiki or the readme of this project (right now, I have this only as local notes)

dsm6 to dsm7

I have successfully migrated/updated from a very old synology gitlab instance to this gitlab-ce, all on dsm6. I'm still only at 13.1.11, but slowly making my way up.
I wonder:

  • how do I switch to dsm7? anything I have to do to my installed gitlab-ce?
  • the upgrade path tool does not let me select your latest release exactly, only 16.2.9 or 16.3.7 - do I need to arrive at one of your releases here, or can I just upgrade to the latest one myself (atm 17.1.0)?

Thank you

unclear install instructions

The wizard says that one needs to run the ssh cmd after the installation completes.

On its last page, the wizard has a tick box to directly start the package afterwards. I guess this has no effect but clarification would be great

URL issue

Despite most stuff working fine, there is one issue, I couldn't resolve:

  • the external url of the gitlab (e.g., one it provides the cloning URL) is: synology-gitlab-ce (which is not even a correct url)
  • so I attempted to modify this:
  1. ssh to NAS and bash into the docker container (as per above)
  2. edit the external URL as per https://docs.gitlab.com/omnibus/settings/configuration.html
  3. sudo docker exec -t "synology-gitlab-ce" bash -c "gitlab-ctl reconfigure"
  4. sudo docker exec -t "synology-gitlab-ce" bash -c "gitlab-ctl restart"

Unfortunately, this didn't work: even though, there were no obvious error messages (there was a huge amount of output to "reconfigure"), when everything was finished, even after several minutes no access was possible, i.e., Gitlab was no longer available at the URL, it was available previously as this was the URL used for reconfiguration.
(http://xyz.synology.me:30080/

However, I could successfully revert the process, luckily.

Cannot support DSM7.1

Do you plane to support DSM7.1?
The DSM7.1's docker is change name to "container manager" so I cannot install Synology-girl lab-ce anymore.

No migration Path for DSM6 latest GitLab 13.12.2 avaible

The latest update on DSM 6.0 for gitlab is 13.12.2 but there is no such release in here.
Therefore no migration path possible as described.
Is it possible to create a release 13.12.2 for the one who like to migrate to your synlogogy-gitlab-ce before upgrading the the DSM to 7.x like me.

build clarifications

It is not clear to me:
Is it required to build on a Synology NAS or can we build on any Linux system?
Could you clarify this in the readme?

Please define a license for this

Clearly the underlying gitlab-ce is covered by their license.

Please write something to describe the license you apply to your changes / adaptations for Synology use. Doing so will provide users with clarity and peace of mind.

I suspect you are pretty flexible about license terms and this is not a big limitation. I suspect the gitlab or synology folk would happy to help you figure out what makes sense if that kind of help is needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.