-
Notifications
You must be signed in to change notification settings - Fork 0
Home
- There's going to be a few individual
docker-compose-__.yml
file examples. So you can either continuously merge them into one finaldocker-compose.yml
file or keep them separated. Which ever suits you. - used constants:
-
/opt/gitlab/
- I'll assume that all the configuration files and/or installed stuff will be at the "root" folder/opt/gitlab/
, because it seems like the right place to put all the configuration at. So you can either choose your own "root" folder or just accept this one. -
mydomain.com
- this domain name will be used as an example. You need to replace it everywhere with your own, already existing, domain name. The steps that includemydomain.com
will be marked with "(👷 containsmydomain.com
)".
-
- Lines with the ➡️ emoji are the actual steps to take, everything else are just useful notes.
1. Install Docker engine
➡️ https://docs.docker.com/engine/install/
2. Install Docker compose
➡️ https://docs.docker.com/compose/install/
3. Create a common Docker network gitlab
➡️ $ docker network create -d bridge gitlab
This will allow you to easily expose the container services under different (sub)domain names on the same server (all under SSL thanks to Let's encrypt).
Take note of the vhost volume at the bottom of the compose file. This configuration syncs the local folder /opt/gitlab/nginx/vhost.d/
with the nginx containers. This allows for easy use of custom nginx configuration per-VIRTUAL_HOST if needed.
➡️ docker-compose-nginx-proxy.yml
Sources:
- https://github.com/nginx-proxy/nginx-proxy
- https://github.com/nginx-proxy/acme-companion/blob/main/docs/Docker-Compose.md
1. Set up the volumes location
➡️ https://docs.gitlab.com/ee/install/docker.html#set-up-the-volumes-location
2. Install GitLab using Docker Compose
➡️ docker-compose-gitlab.yml (👷 contains mydomain.com
)
3. Check the public accessibility of the GitLab server
4. Get the root password
➡️ In the file initial_root_password
(accessible via sudo cat /srv/gitlab/config/initial_root_password
) should be the root password that you can use for logging in to the "root" account.
5. Configure sign-up restrictions
➡️ At /admin/application_settings/general#js-signup-settings
you should disable new, unapproved sign-ups for your GitLab server.
6. Add SSH keys
➡️ At /-/profile/keys
add an SSH key that will allow you to actually push code to your GitLab server. See https://docs.gitlab.com/16.4/ee/user/ssh.html.
➡️ Add SSH config: (👷 contains mydomain.com
)
Host gitlab.mydomain.com
HostName <your_server_IP>
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_iusethisfortesting_sentisso
HostName
can be left out if your DNS servers support the SSH protocol (for example Proxied Cloudflare does not).
7. Disable Auto DevOps
➡️ At /admin/application_settings/ci_cd#js-ci-cd-settings
uncheck the "Default to Auto DevOps pipeline for all projects" option to disable Auto DevOps at the instance level.
8. Enable large body uploads
This is especially useful when you want to import projects from other sources.
➡️ Create file /opt/gitlab/nginx/vhost.d/gitlab.mydomain.com
with the following contents: (👷 contains mydomain.com
)
client_max_body_size 64m;
Sources:
GitLab runners can be installed and ran on any server! Not just the root one, which hosts the GitLab server.
1. Install a new Docker GitLab runner
➡️ docker-compose-gitlab-runner.yml
2. Register the GitLab runner
➡️ In the admin settings at /admin/runners/new
"create" a new GitLab runner.
➡️ After submitting the form, remember/copy the runner token glrt-***
, which is shown on the confirmation page.
➡️ On the server where you created the Docker GitLab runner, run docker compose exec gitlab-runner gitlab-runner register
(where the first gitlab-runner
is the container name of the runner). It will ask you for:
- the public URL of your GitLab server:
https://gitlab.mydomain.com/
(👷 containsmydomain.com
), - runner authentication token: that's the
glrt-***
token from earlier, - runner executor: use
docker
- default image: use
alpine:latest
➡️ Edit the runner's configuration at /srv/gitlab-runner/config/config.toml
:
- Add
"/var/run/docker.sock:/var/run/docker.sock:ro"
tovolumes
in the[runners.docker]
section, - Add
network_mode = "host"
in the[runners.docker]
section
➡️ Restart the GitLab runner by running docker compose exec gitlab-runner gitlab-runner restart
4. Check the availability of the runner
➡️ At /admin/runners
it should have a status of "Online", including some information about the server where you deployed the runner at.
Sources:
- https://docs.gitlab.com/runner/install/docker.html
- https://docs.gitlab.com/runner/register/index.html#docker
If you've completed the previous steps, you can start developing and deploying new applications on your self-hosted GitLab server. The following sections are therefore optional, but are recommended and could be pretty useful.
Sources:
Configure SMTP for proper email notifications support.
The gitlab.rb
file, that you should edit, is located at /srv/gitlab/config/gitlab.rb
.
➡️ Follow the instructions for your email solution at https://docs.gitlab.com/omnibus/settings/smtp.html
➡️ Reconfigure the server by running docker compose exec gitlab gitlab-ctl reconfigure