Gitlab
sdg-gitlab provides a 👉 docker-compose.yml file, which can be easily converted to a dokku config with 👉 dokkupose.netlify.app.
This results in the following bash script:
# sdg-gitlab
dokku apps:create sdg-gitlab
dokku domains:add sdg-gitlab gitlab.domain.ch
dokku ports:add sdg-gitlab http:80:80
# eventually open ssh port aswell. docker options must be used here.
# See https://github.com/dokku/dokku/issues/2383#issuecomment-242591167 for more details how to do this.
# dokku docker-options:add sdg-gitlab deploy -p 2222:22
# create the storage directory with permissions for root 0:0
dokku storage:ensure-directory --chown root sdg-gitlab
mkdir -p /var/lib/dokku/data/storage/sdg-gitlab/config
chown -R 0:0 /var/lib/dokku/data/storage/sdg-gitlab/config
dokku storage:mount sdg-gitlab /var/lib/dokku/data/storage/sdg-gitlab/config:/etc/gitlab
mkdir -p /var/lib/dokku/data/storage/sdg-gitlab/logs
chown -R 0:0 /var/lib/dokku/data/storage/sdg-gitlab/logs
dokku storage:mount sdg-gitlab /var/lib/dokku/data/storage/sdg-gitlab/logs:/var/log/gitlab
mkdir -p /var/lib/dokku/data/storage/sdg-gitlab/data
chown -R 0:0 /var/lib/dokku/data/storage/sdg-gitlab/data
dokku storage:mount sdg-gitlab /var/lib/dokku/data/storage/sdg-gitlab/data:/var/opt/gitlab
# configure environment of sdg-gitlab - important to use http:// and not https protocol, since sdg-gitlab runs behind
# the nginx reverse proxy!
dokku config:set sdg-gitlab GITLAB_OMNIBUS_CONFIG="external_url 'https://gitlab.domain.ch'; nginx['listen_port'] = 80; nginx['listen_https'] = false;"
# set resource limits for sdg-gitlab
dokku resource:limit --cpu 2 --memory 4gb --memory-swap 8gb sdg-gitlab
# set log level to warn to reduce log size [debug, info, warn, error, fatal, unknown]
dokku config:set --no-restart sdg-gitlab GITLAB_LOG_LEVEL=warn
# assign image to sdg-gitlab
dokku git:from-image sdg-gitlab gitlab/gitlab-ee:18.10.0-ee.0
# optional: letsencrypt
dokku domains:remove sdg-gitlab sdg-gitlab.fs-inf-26
dokku letsencrypt:enable sdg-gitlab
Admin login​
To get the initial admin password, the password must be reset:
dokku enter sdg-gitlab
gitlab-rake "gitlab:password:reset"
COnfigure Log Level​
To reduce the log size, the log level can be set to warn:
gitlab_rails['env'] = {
"GITLAB_LOG_LEVEL" => "WARN",
}
registry['log_level'] = 'warn'
gitlab_shell['log_level'] = 'WARN'
gitaly['configuration'] = {
logging: {
level: "warn"
}
}
Configuring Mail​
You can modify the gitlab.rb file directly on your host system:
nano /var/lib/dokku/data/storage/sdg-gitlab/config/gitlab.rb
... and set the following config options:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "authsmtp.securemail.pro"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "foo@bar.ch"
gitlab_rails['smtp_password'] = "PW"
gitlab_rails['smtp_domain'] = "bar.ch"
gitlab_rails['smtp_authentication'] = "plain"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'foo@bar.ch'
gitlab_rails['gitlab_email_display_name'] = 'GitLab GBSL'
gitlab_rails['gitlab_email_reply_to'] = 'foo@bar.ch'
After this, you need to reconfigure gitlab, by entering the running container and run reconfigure
# enter the docker container spawned by dokku
dokku enter sdg-gitlab
# and the reconfigure inside the container
gitlab-ctl reconfigure
# check if you can send an email:
gitlab-rails console
and run
Notify.test_email('USERNAME@gmail.com', 'Message Subject', 'Message Body').deliver_now
Reconfigure​
dokku run sdg-gitlab gitlab-ctl reconfigure
Reduce Memory usage​
Beside the docker resource limits set over dokku resource:limit, you can also set some configuration options to reduce the memory usage of gitlab. This is especially important if you run gitlab on a small server with limited resources. The following configuration options can be set in the gitlab.rb file:
👉 https://docs.gitlab.com/omnibus/settings/memory_constrained_envs/
# Performance optimizations
# @see https://docs.gitlab.com/omnibus/settings/memory_constrained_envs/
# Reduce sidekiq concurrency
sidekiq['concurrency'] = 2
postgresql['shared_buffers'] = "256MB"
# use only a single puma server and no worker
puma['worker_processes'] = 0
# LOG Level
registry['log_level'] = 'warn'
gitlab_shell['log_level'] = 'WARN'
# release memory back to os all 1s
gitlab_rails['env'] = {
'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000',
"GITLAB_LOG_LEVEL" => "WARN"
}
gitaly['configuration'] = {
logging: {
level: "warn"
},
concurrency: [
{
'rpc' => "/gitaly.SmartHTTPService/PostReceivePack",
'max_per_repo' => 3,
}, {
'rpc' => "/gitaly.SSHService/SSHUploadPack",
'max_per_repo' => 3,
},
]
}
gitaly['env'] = {
'GITALY_COMMAND_SPAWN_MAX_PARALLEL' => '2',
'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000'
}
alertmanager['enable'] = false
gitlab_exporter['enable'] = false
gitlab_kas['enable'] = false
node_exporter['enable'] = false
postgres_exporter['enable'] = false
prometheus_monitoring['enable'] = false
prometheus['enable'] = false
puma['exporter_enabled'] = false
redis_exporter['enable'] = false
sidekiq['metrics_enabled'] = false