Skip to content

Instantly share code, notes, and snippets.

@fzliu
Created June 23, 2021 04:12
Show Gist options
  • Save fzliu/02cbaa8702a0a14c4100541d0ed81af5 to your computer and use it in GitHub Desktop.
Save fzliu/02cbaa8702a0a14c4100541d0ed81af5 to your computer and use it in GitHub Desktop.
Gitlab minimal memory installation via docker.
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
# Add any other gitlab.rb configuration here, each on its own line
puma['worker_processes'] = 0
sidekiq['max_concurrency'] = 10
prometheus_monitoring['enable'] = false
gitlab_rails['env'] = {'MALLOC_CONF' => 'dirty_decay_ms:1000, muzzy_decay_ms:1000'}
gitaly['cgroups_count'] = 2
gitaly['cgroups_mountpoint'] = '/sys/fs/cgroup'
gitaly['cgroups_hierarchy_root'] = 'gitaly'
gitaly['cgroups_memory_enabled'] = true
gitaly['cgroups_memory_limit'] = 250000
gitaly['cgroups_cpu_enabled'] = true
gitaly['cgroups_cpu_shares'] = 512
gitaly['concurrency'] = [{'rpc' => "/gitaly.SmartHTTPService/PostReceivePack", 'max_per_repo' => 3}, {'rpc' => "/gitaly.SSHService/SSHUploadPack", 'max_per_repo' => 3}]
gitaly['env'] = {'LD_PRELOAD' => '/opt/gitlab/embedded/lib/libjemalloc.so', 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000', 'GITALY_COMMAND_SPAWN_MAX_PARALLEL' => '2'}
ports:
- '80:80'
- '443:443'
volumes:
- '/var/lib/gitlab/config:/etc/gitlab'
- '/var/lib/gitlab/logs:/var/log/gitlab'
- '/var/lib/gitlab/data:/var/opt/gitlab'
@strarsis
Copy link

@fzliu: Thanks! But when I use cgroups options the authentication with / startup of the Postgres database server fails:

gitlab      | ==> /var/log/gitlab/postgresql/current <==
gitlab      | 2022-04-21_20:45:48.56752 LOG:  database system is ready to accept connections
gitlab      | 2022-04-21_20:45:49.81582 LOG:  no match in usermap "gitlab" for user "gitlab" authenticated as "root"
gitlab      | 2022-04-21_20:45:49.81590 FATAL:  Peer authentication failed for user "gitlab"
gitlab      | 2022-04-21_20:45:49.81591 DETAIL:  Connection matched pg_hba.conf line 70: "local   all         all                               peer map=gitlab"
gitlab      | 2022-04-21_20:45:49.97281 LOG:  no match in usermap "gitlab" for user "gitlab" authenticated as "root"
gitlab      | 2022-04-21_20:45:49.97284 FATAL:  Peer authentication failed for user "gitlab"
gitlab      | 2022-04-21_20:45:49.97284 DETAIL:  Connection matched pg_hba.conf line 70: "local   all         all                               peer map=gitlab"
gitlab      | 2022-04-21_20:45:50.12915 LOG:  no match in usermap "gitlab" for user "gitlab" authenticated as "root"
gitlab      | 2022-04-21_20:45:50.12916 FATAL:  Peer authentication failed for user "gitlab"
gitlab      | 2022-04-21_20:45:50.12917 DETAIL:  Connection matched pg_hba.conf line 70: "local   all         all                               peer map=gitlab"
gitlab      |
gitlab      | ==> /var/log/gitlab/postgresql/state <==
gitlab      | *** buffer overflow detected ***: terminated
gitlab      | xargs: tail: terminated by signal 6

@vogdb
Copy link

vogdb commented Feb 3, 2023

Thanks! But when I use cgroups options the authentication with / startup of the Postgres database server fails:

@strarsis I also have this problem. Now I'm running without gitaly['cgroups optimizations and it already takes 1Gb less than before. How did you solve cgroups problem?

@strarsis
Copy link

strarsis commented Feb 3, 2023

@vogdb: I commented the cgroups related parts out. The other settings helped with memory consumption.
It is not perfect though. I update GitLab regularly, which should also help with memory-consumption and memory-related issues.

@vogdb
Copy link

vogdb commented Feb 3, 2023

@vogdb: I commented the cgroups related parts out.

:D I've made the same. Thanks for the feedback!

@strarsis
Copy link

strarsis commented Mar 4, 2023

@vogdb:
Follow up: After updating to recent GitLab (GitLab CE 15.8.1), the memory issues (system lock ups that require rebooting) went away.

@vogdb
Copy link

vogdb commented Mar 4, 2023

@strarsis thank you for the feedback. I will try it too.

@strarsis
Copy link

strarsis commented Mar 4, 2023

@vogdb: Reminder: When updating GitLab, update first to latest minor release (e.g. from 14.8.2 to 14.8.9), then start GitLab and when it is running (Docker container status from health: starting to healthy), update to first minor version of the next major release (e.g. from 14.8.9. to 15.0.0). Then repeat until you reached the desired (usually the latest) GitLab release. Jumping releases often won't work and you have to downgrade back to the previous version and go up by minor version, as described above.

@vogdb
Copy link

vogdb commented Mar 5, 2023

@strarsis ok, will do. Thanks again.

@strarsis
Copy link

strarsis commented Sep 4, 2024

@vogdb: Note that with GitLab 17 the options sidekiq['max_concurrency'] and gitaly['ruby_max_rss'] were removed and have to be removed from docker-compose.yml in order to allow GitLab to start up (reconfiguration step during startup).

@vogdb
Copy link

vogdb commented Sep 4, 2024

@strarsis Thanks! I'm still on the latest 15 >_<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment