Herramientas de usuario

Herramientas del sitio


gentoo:gitlab-ce

¡Esta es una revisión vieja del documento!


GitLab Community Edition installation (using docker)

Although it is possible to install GitLab directly on Gentoo , this guide will cover the installation of the GitLab Community Edition using docker.

Install and run docker on Gentoo

First of all, you should install the docker package:

emerge -avq app-emulation/docker

During the installing, please check the emerge messages for missing options in the current kernel.

Once installed, you should check if the system is properly configured for running dockers with:

/usr/share/docker/contrib/check-config.sh

Enable and start the docker service:

systemctl enable docker
systemctl start docker

Install and run the GitLab CE docker

Download the official GitLab Community Edition Docker image from Docker Hub [1] using the following command:

docker pull gitlab/gitlab-ce

To run the docker instance, check the GitLab Docker images documentation.

Docker commands

To start/restart/stop the gitlab docker (once defined following the previous section link):

docker start gitlab
docker restart gitlab
docker stop gitlab

To see which dockers are running:

docker ps

To see the logs of the gitlab docker:

docker exec gitlab gitlab-ctl tail

To execute a bash inside the gitlab docker:

docker exec -it gitlab /bin/bash

NFS caveats

The NFS server and client can be fine tuned following the GitLab NFS documentation.

If '/var/opt/gitlab' is not writable errors occur (which can be checked with docker exec gitlab gitlab-ctl tail), these can be avoided after starting the gitlab docker by changing the owner of /var/opt/gitlab to git. Also, the noac nfs4 mount option should be used on the NFS client to prevent attributes to be cached and, therefore, to allow the previous change to be accounted for as soon as possible.

This change can be made permanent, patching /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb as follows::

--- /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb.orig     2019-10-03 13:39:21.826524552 +0000
+++ /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb    2019-10-03 13:41:03.499281744 +0000
@@ -45,6 +45,11 @@
   action :create
 end
 
+directory "/var/opt/gitlab" do
+  owner "git"
+  action :create
+end
+
 directory "Create /var/log/gitlab" do
   path "/var/log/gitlab"
   owner "root"

The '/var/opt/gitlab' is not writable errors are caused when testing if the directory /var/opt/gitlab/.bundle is writable by the user git. The stats() function says that is not writable unless its parent is also writable by that user. This can be tested with the following command:

docker exec gitlab su - git -c "[ -w /var/opt/gitlab/.bundle ] || echo 'no writable'"

Upgrade the container

1. Check the digest number of the current version with:

docker images --digests | grep gitlab-ce | grep latest | grep sha256:

2. Compare the first digits of the digest number with those of the lastes version in: <https://hub.docker.com/r/gitlab/gitlab-ce/tags>.

3. Stop and delete the current image, then pull the new version:

docker stop gitlab
docker rm gitlab
docker pull gitlab/gitlab-ce

4. If an NFS mount point is used and the '/var/opt/gitlab' is not writable' error occurs, then apply the previously shown patch: <code bash> # Run the image once using bash as entry point: docker run -it –entrypoint bash gitlab/gitlab-ce # Apply the previous patch on default.rb: nano /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb # Create new image from ID (it appears in the prompt, e.g. root@9ffa2bafe2bb:/#), docker commit 9ffa2bafe2bb my-gitlab-ce </code> 5. Run the image <code bash> docker run –detach \ […] –name gitlab \ –restart always \ –volume /srv/gitlab/config:/etc/gitlab \ –volume /srv/gitlab/logs:/var/log/gitlab \ –volume /srv/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest # or my-gilab-ce </code> 5. Cleanup previous images: <code bash> docker rmi $(docker images -f “dangling=true” -q) </code> ===== Backup and restore ===== The backup strategy described next generates a backup file with a fixed name that will be incrementally backed up using an external tool. The container name is assumed to be gitlab. 1. Call the gitlab-backup tool (see Backing up and restoring GitLab for an explanation of the options being used): <code bash> docker exec -t gitlab gitlab-backup create STRATEGY=copy BACKUP=dump GZIP_RSYNCABLE=yes </code> 2. Use a backup tool to backup the following dirs: <code> /srv/gitlab/config/ /srv/gitlab/data/backups/ </code> To restore a given backup, restore the previous dirs and follow the instructions in Backing up and restoring GitLab. The next procedure assumes that: You have installed the exact same version and type (CE/EE) of GitLab Omnibus with which the backup was created. * You have run gitlab-ctl reconfigure at least once. * GitLab is running. If not, start it using gitlab-ctl start. * First make sure your backup tar file is in the backup directory (/var/opt/gitlab/backups''). It needs to be owned by the git user.

cp gitlab-ce-12.3.4_gitlab_backup.tar /srv/gitlab/data/backups/
docker exec -it gitlab bash
chown git.git /var/opt/gitlab/backups/*

Stop the processes that are connected to the database. Leave the rest of GitLab running:

sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
# Verify
sudo gitlab-ctl status

Next, restore the backup, specifying the name part of the backup you wish to restore:

# This command will overwrite the contents of your GitLab database! gitlab-backup restore BACKUP=gitlab-ce-12.3.4  Note For GitLab 12.1 and earlier, use gitlab-rake gitlab:backup:restore. Warning: gitlab-rake gitlab:backup:restore does not set the right file system permissions on your Registry directory. This is a known issue. On GitLab 12.2 or newer, you can use gitlab-backup restore to avoid this issue. Next, restore /etc/gitlab/gitlab-secrets.json if necessary as mentioned above.

Reconfigure, restart and check GitLab:

sudo gitlab-ctl reconfigure sudo gitlab-ctl restart sudo gitlab-rake gitlab:check SANITIZE=true

References

gentoo/gitlab-ce.1570266832.txt.gz · Última modificación: 2019/10/05 09:13 por barrachi