GitLab
Section titled “ GitLab”GitLab is the complete DevOps platform.
- Questions? Ask in the Cloudron Forum - GitLab
- GitLab Website
- GitLab forum
- GitLab issue tracker
Custom gitlab.yml
Section titled “Custom gitlab.yml”Customize GitLab using GitLab’s admin interface. Some options can only be
changed in gitlab.yml. Use the File Manager
to modify /app/data/gitlab.yml and restart the app.
Disabling registration
Section titled “Disabling registration”By default, GitLab allows external people to sign up. Disable this to restrict use only to Cloudron users:
GitLab > Admin area > Settings > Features > remove the check mark “Sign-up enabled”
GitLab runner for CI
Section titled “GitLab runner for CI”GitLab CI involves installing one or more GitLab Runners. These runners carry out tasks as instructed by the main GitLab installation. When installing a runner, you have to select the project tags to which the runner will respond and the type of tasks (“executor”) it can carry out. Examples include the Shell executor, Docker executor, etc.
Once GitLab runner is installed, you have to add the runner in GitLab. When adding the runner in GitLab, you can decide how GitLab schedules tasks in the runner ie. if the runner is exclusive to a project (‘Specific Runner’) or shared between projects (’Shared Runner) or specific to a group (‘Group Runner’).
Use Cloudron’s GitLab package with GitLab Runner:
- Create a new server and install GitLab Runner on it using the instructions at GitLab docs. In short:
# For ubuntucurl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bashsudo apt-get install gitlab-runner-
Get the token from GitLab under
https://<gitlab.example.com>/admin/runners(under shared runners section). -
Register the runner with the token from the above step
sudo gitlab-runner registerRunning in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):https://gitlab.cloudron.xyzPlease enter the gitlab-ci token for this runner:xzdZgdsXq5uSFCyAK7pPPlease enter the gitlab-ci description for this runner:[localhost]: Shell Jobs RunnerPlease enter the gitlab-ci tags for this runner (comma separated):
Whether to lock the Runner to current project [true/false]:[true]: falseRegistering runner... succeeded runner=xzdZgdsXPlease enter the executor: docker, docker-ssh, shell, ssh, virtualbox, docker-ssh+machine, parallels, docker+machine, kubernetes:shellRunner registered successfully. Feel free to start it, but if it is running already, the config should be automatically reloaded!-
The Runner should now be listed under
https://<gitlab.example.com>/admin/runners. -
Now push a .gitlab-ci.yml to your project to start using the runner.
Rails console
Section titled “Rails console”To open a rail console, first open the Web terminal and then run:
gosu git:git bundle exec rails c -e productionReset admin password
Section titled “Reset admin password”To reset the admin password, run the following commands using the Web terminal:
gosu git:git bundle exec rails c -e production=> user = User.where(id: 1).first=> user.password = 'NEW_PASS'=> user.password_confirmation = 'NEW_PASS'=> user.save=> exitApp settings
Section titled “App settings”GitLab supports various other settings via gitlab.rb. On Cloudron, these are specified in /app/data/gitlab.yml.
The upstream docs are referring to the key style of gitlab.rb and the mapping of keys for the yml file are described here.
Incoming email
Section titled “Incoming email”GitLab has several features based on receiving incoming email messages:
- Reply by Email
- New issue by Email
- New merge request by email
- Service Desk.
See the upstream docs for more information.
Set up
Section titled “Set up”When not using Cloudron Email server, configure production.incoming_email in /app/data/gitlab.yaml with
the IMAP information. The mailroom service automatically starts when production.incoming_email.enabled
is set to true (verify using supervisorctl status in the Web Terminal).
When using Cloudron Email on the same server as the Gitlab installation:
-
Create a mailbox like
git@cloudron.space -
Set the inbox to use in the
Emailsection of the app. When configured, Cloudron configures GitLab to use Email sub-addressing and enables themailroomservice.
Testing
Section titled “Testing”-
Reply by Email - Each issues has a per user email address. Click on the ribbon in the issue page to find this address.
-
New issue by Email - You will find the unique email address per user in the issues page of the project.
-
Service Desk - Enable this for a project in Settings -> General -> Service Desk. The support desk email address is displayed here.
-
Service Desk custom address - This step is only required if you want to a set a different support email address than the incoming email address. To set a custom Service Desk address which is shared for the full instance, add a section
service_desk_emailin/app/data/gitlab.ymlas mentioned here:
production: &base ... other configs ...
service_desk_email: enabled: true address: "project_contact+%{key}@example.com" user: "project_contact@example.com" password: "[REDACTED]" host: "my.cloudrondomain.com" port: 993 ssl: true start_tls: false log_path: "log/mailroom.log" mailbox: "inbox" idle_timeout: 60 expunge_deleted: trueBe sure to restart GitLab after making the above changes.
Migration to Cloudron
Section titled “Migration to Cloudron”This guide helps migrate an already running Gitlab into the Gitlab Cloudron app.
Seek help in the Forum for any problems.
This guide covers migration from a Gitlab installation via Omnibus.
Also in the converted `secrets.yml` you will need to change `gitlab_rails:` to `production:` - otherwise gitlab will generate new secrets for rails.Create a backup of your running GitLab
Section titled “Create a backup of your running GitLab”Save the generated file I.e. 1632462433_2021_09_24_14.2.4_gitlab_backup.tar on your local computer.
Change the database owner in the created backup
Section titled “Change the database owner in the created backup”In the Omnibus version the default user for the database was gitlab in my case.
You need to change this into the PostgreSQL user provided by Cloudron.
Go into the Web terminal of your Cloudron Gitlab app to get the username:
# Echoing the single variableecho $CLOUDRON_POSTGRESQL_USERNAMEuserd5499e3cf81b43d093724d69fa223688
# Getting all PostgreSQL variablesprintenv | grep -i POSTGRESCLOUDRON_POSTGRESQL_URL=postgres://userd5499e3cf81b43d093724d69fa223688:ab1569471419f341ed83f18538b275c09c1389fdb248398640d48fdc8847275858aeca488021da55edb460051a2a0595f226602afc7828becd1c17d91f55eee2@postgresql/dbd5499e3cf81b43d093724d69fa223688CLOUDRON_POSTGRESQL_DATABASE=dbd5499e3cf81b43d093724d69fa223688CLOUDRON_POSTGRESQL_PASSWORD=ab1569471419f341ed83f18538b275c09c1389fdb248398640d48fdc8847275858aeca488021da55edb460051a2a0595f226602afc7828becd1c17d91f55eee2CLOUDRON_POSTGRESQL_USERNAME=userd5499e3cf81b43d093724d69fa223688CLOUDRON_POSTGRESQL_HOST=postgresqlCLOUDRON_POSTGRESQL_PORT=5432The content of the backup looks like this:
1632462433_2021_09_24_14.2.4_gitlab_backup/├── artifacts.tar.gz├── backup_information.yml├── builds.tar.gz├── db│ └── database.sql.gz├── lfs.tar.gz├── pages.tar.gz├── repositories│ └── @hashed└── uploads.tar.gzExtract the database.sql.gz to edit the database.sql.
We will need to replace all OWNER TO gitlab; strings to OWNER TO userd5499e3cf81b43d093724d69fa223688;.
Save the database.sql and gzip the file back into the database.sql.gz.
Put it back together into the 1632462433_2021_09_24_14.2.4_gitlab_backup.tar.
Example all done in a terminal:
# Move the created backup into a seperate folder for extraction# Extract the created tartar -xf 1632745419_2021_09_27_14.2.4_gitlab_backup.tar
# Decompress the gziped database.sql.gzgzip -d db/database.sql.gz
# replace all `OWNER TO gitlab;` with `OWNER TO OWNER TO userd5499e3cf81b43d093724d69fa223688;`sed -e 's/OWNER TO gitlab;/OWNER TO userd5499e3cf81b43d093724d69fa223688;/' -i db/database.sql
# compress the `database.sql`gzip db/database.sql
# Create the new `1632745419_2021_09_27_14.2.4_gitlab_backup.tar`# You will get a warning since it wont tar it selftar -cf 1632745419_2021_09_27_14.2.4_gitlab_backup.tar ./tar: ./1632745419_2021_09_27_14.2.4_gitlab_backup.tar is the archive; not backed up.Restoring the backup
Section titled “Restoring the backup”- Upload the new tar to the Gitlab Cloudron app to
/app/data/backups/1632745419_2021_09_27_14.2.4_gitlab_backup.tar. - Upload the converted
secrets.ymlto/app/data/secrets.yml - Create a snapshot of the running Cloudron Gitlab app (this way we can jump back if something does not work, and you won’t need to re-upload the backup)
- Open the Web terminal of the Cloudron Gitlab app and run the restore
GITLAB_ASSUME_YES=1 gosu git:git bundle exec rake --trace gitlab:backup:restore RAILS_ENV=productionNow the restore should start looking something like this:
`/home/git` is not writable.Bundler will use `/tmp/bundler20210927-435-134v1je435' as your home directory temporarily.. . .2021-09-24 06:22:36 +0000 -- done2021-09-24 06:22:36 +0000 -- Restoring uploads ...2021-09-24 06:22:36 +0000 -- done2021-09-24 06:22:36 +0000 -- Restoring builds ...2021-09-24 06:22:36 +0000 -- done2021-09-24 06:22:36 +0000 -- Restoring artifacts ...2021-09-24 06:22:36 +0000 -- done2021-09-24 06:22:36 +0000 -- Restoring pages ...2021-09-24 06:22:36 +0000 -- done2021-09-24 06:22:36 +0000 -- Restoring lfs objects ...2021-09-24 06:22:36 +0000 -- doneNow migrate your custom settings from the gitlab.rb settings into /app/data/gitlab.yml file.
Restart the Cloudron Gitlab app.
Now everything should work as intended.
Migration of GitLab users to Cloudron LDAP users
Section titled “Migration of GitLab users to Cloudron LDAP users”You might want to link old Gitlab users to the new Cloudron LDAP Users. This is rather simple, just make sure the username of the user is the same as in Cloudron.
Example:
Gitlab username is tina.testing so the Cloudron username should also be tina.testing