GitLab is a self-hosted alternative to GitHub. The most common use case is (a set of) developers with the desire for the rich feature-set of GitHub, but with unlimited private repositories.
Docker does maintain an official "Omnibus" container, but for this recipe I prefer the "dockerized gitlab" project, since it allows distribution of the various Gitlab components across multiple swarm nodes.
Setup data locations¶
We'll need several directories to bind-mount into our container, so create them in /var/data/gitlab:
1 2 3 4
You'll need to know the following:
- Choose a password for postgresql, you'll need it for DB_PASS in the compose file (below)
- Generate 3 passwords using
pwgen -Bsv1 64. You'll use these for the XXX_KEY_BASE environment variables below
- Create gitlab.env, and populate with at least the following variables (the full set is available at https://github.com/sameersbn/docker-gitlab#available-configuration-parameters):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
DB_USER=gitlab DB_PASS=gitlabdbpass DB_NAME=gitlabhq_production DB_EXTENSION=pg_trgm DB_ADAPTER=postgresql DB_HOST=postgresql TZ=Pacific/Auckland REDIS_HOST=redis REDIS_PORT=6379 GITLAB_TIMEZONE=Auckland GITLAB_HTTPS=true SSL_SELF_SIGNED=false GITLAB_HOST=gitlab.example.com GITLAB_PORT=443 GITLAB_SSH_PORT=2222 GITLAB_SECRETS_DB_KEY_BASE=CFf7sS3kV2nGXBtMHDsTcjkRX8PWLlKTPJMc3lRc6GCzJDdVljZ85NkkzJ8mZbM5 GITLAB_SECRETS_SECRET_KEY_BASE=h2LBVffktDgb6BxM3B97mDSjhnSNwLc5VL2Hqzq9cdrvBtVw48WSp5wKj5HZrJM5 GITLAB_SECRETS_OTP_KEY_BASE=t9LPjnLzbkJ7Nt6LZJj6hptdpgG58MPJPwnMMMDdx27KSwLWHDrz9bMWXQMjq5mp GITLAB_ROOT_PASSWORD=changeme
Setup Docker Swarm¶
Create a docker swarm config file in docker-compose syntax (v3), something like this:
I share (with my patreon patrons) a private "premix" git repository, which includes necessary docker-compose and env files for all published recipes. This means that patrons can launch any recipe with just a
git pull and a
docker stack deploy 👍
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Setup unique static subnets for every stack you deploy. This avoids IP/gateway conflicts which can otherwise occur when you're creating/removing stacks a lot. See my list here.
Launch the mail server stack by running
docker stack deploy gitlab -c <path -to-docker-compose.yml>
Log into your new instance at https://[your FQDN], with user "root" and the password you specified in gitlab.env.
Chef's Notes 📓¶
A few comments on decisions taken in this design:
- I use the sameersbn/gitlab:latest image, rather than a specific version. This lets me execute updates simply by redeploying the stack (and why wouldn't I want the latest version?)
Tip your waiter (support me) 👏¶
Did you receive excellent service? Want to make your waiter happy? (..and support development of current and future recipes!) See the support page for (free or paid) ways to say thank you! 👏
Flirt with waiter (subscribe) 💌¶
Want to know now when this recipe gets updated, or when future recipes are added? Subscribe to the RSS feed, or leave your email address below, and we'll keep you updated. (double-opt-in, no monkey business, no spam either - check the archive for proof!)