GitLab #
I have recently started using a selfhosted version of gitlab.
I have it running on a VM with 4 cores and 4GB of memory. It is running with docker compose.
The installation is done via ansible.
I have created a role gitlab. In the tasks folder I created a main.yml file that contains the following:
# roles/gitlab/tasks/main.yml
---
- name: Ensure docker python libraries are installed
ansible.builtin.apt:
name:
- python3-docker
- python3-yaml
state: present
update_cache: true
- name: Create GitLab directories on host
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
loop:
- /srv/gitlab/config
- /srv/gitlab/logs
- /srv/gitlab/data
- name: Create docker-compose.yml from template
ansible.builtin.template:
src: docker-compose.yml.j2
dest: /srv/gitlab/docker-compose.yml
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0644'
- name: Create and start the GitLab container
community.docker.docker_compose_v2:
project_src: /srv/gitlab
state: present # Ensures the service is running
and it needed a template file in the templates folder of the role
# roles/gitlab/templates/docker-compose.yml.j2
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: '{{ ansible_host }}'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://{{ ansible_host }}'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
ports:
- '80:80'
- '443:443'
- '2222:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab'
- '/srv/gitlab/logs:/var/log/gitlab'
- '/srv/gitlab/data:/var/opt/gitlab'
the TL;DR #
just as a quick reminder: In practice, your day-to-day workflow will often just be these three commands:
# 1. Add all changes
git add .
# 2. Commit them with a message
git commit -m "A message describing what I did"
# 3. Push them to GitLab
git push