项目作者: toshi0123

项目描述 :
docker image for gitlab-ce based on alpine linux
高级语言: Shell
项目地址: git://github.com/toshi0123/gitlab-ce.git
创建时间: 2017-10-24T12:43:03Z
项目社区:https://github.com/toshi0123/gitlab-ce

开源协议:MIT License

下载


gitlab-ce on alpine linux

Docker Repository on Quay

This image is under development.

This gitlab-ce container image is built from source files.
You can find the installation guide as follows.
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md

This docker image contains

  1. gitlab-ce(postgres)
  2. gitlab-shell
  3. gitaly
  4. gitlab-workhorse
  5. nginx

Postgresql and redis are not contained in this image.
You have to set them up by yourself.

Quick start

First, you have to create a new network.

  1. docker network create gitlab-network

And run redis. (At this time I use my own redis image.)
You can use library/redis or other redis container images.

  1. docker run --name gitlab-redis \
  2. -d \
  3. --hostname gitlab-redis \
  4. --log-opt max-size=10m \
  5. --log-opt max-file=4 \
  6. -v $PWD/redis:/data \
  7. --network gitlab-network \
  8. quay.io/toshi0123/redis:latest

And run postgresql. (Rails 4 is not supported with Postgresql 10.)
You can use library/postgres:9.6.6-alpine or other postgresql container images.

  1. docker run --name gitlab-postgres \
  2. -d \
  3. --hostname gitlab-postgres \
  4. -e 'POSTGRES_USER=gitlab' \
  5. -e 'POSTGRES_PASSWORD=gitlabpassword' \
  6. -e 'POSTGRES_DB=gitlabhq_production' \
  7. -e 'DB_EXTENSION=pg_trgm' \
  8. --log-opt max-size=10m \
  9. --log-opt max-file=4 \
  10. -v $PWD/postgres:/var/lib/postgresql/data:rw \
  11. --network gitlab-network \
  12. quay.io/toshi0123/postgres:9.6.10-r0

Then, run gitlab. (If you want to set it up with https, you have to read the HTTPS section before starting the gitlab container.)

  1. docker run --name gitlab \
  2. -d \
  3. -p 80:80 \
  4. -p 443:443 \
  5. --hostname gitlab \
  6. -e 'GITLAB_SECRETS_DB_KEY_BASE=please-modify-by-yourself' \
  7. -e 'GITLAB_SECRETS_SECRET_KEY_BASE=please-modify-by-yourself' \
  8. -e 'GITLAB_SECRETS_OTP_KEY_BASE=please-modify-by-yourself' \
  9. --log-opt max-size=10m \
  10. --log-opt max-file=4 \
  11. -v $PWD/gitlab/etc:/etc/gitlab:rw \
  12. -v $PWD/gitlab/data:/home/git/data:rw \
  13. -v $PWD/gitlab/log:/var/log:rw \
  14. --network gitlab-network \
  15. quay.io/toshi0123/gitlab-ce:latest

Wait for gitlab to start up.

  1. $ docker logs gitlab -f
  2. ...
  3. The GitLab Unicorn web server with pid 132 is running.
  4. The GitLab Sidekiq job dispatcher with pid 230 is running.
  5. The GitLab Workhorse with pid 170 is running.
  6. Gitaly with pid 178 is running.
  7. GitLab and all its components are up and running.
  8. + /usr/sbin/crond -L /var/log/crond.log
  9. + set +x

And now you can access http://127.0.0.1 in your browser.
The first time you access the URL, you can change your root account’s password. Then you can log in as root.

All data and config, log files are in $PWD/redis and $PWD/postgres and $PWD/gitlab directories.
Please maintain these carefully.

Environment variables

variables example values description
DB_HOST gitlab-postgres Postgresql host(default: gitlab-postgres)
DB_PORT 5432 Postgresql port(default: 5432)
DB_NAME gitlabhq_production Gitlab DB name(default: gitlabhq_production)
DB_USER gitlab Gitlab DB user’s name(default: gitlab)
DB_PASS gitlabpassword Gitlab DB user’s password(default: gitlabpassword)
REDIS_HOST gitlab-redis Redis-server host(default: gitlab-redis)
REDIS_PORT 6379 Redis-server port(default: 6379)
GITLAB_SECRETS_DB_KEY_BASE very-long-random-string Encryption key(default: default)
GITLAB_SECRETS_SECRET_KEY_BASE very-long-random-string Encryption key(default: default)
GITLAB_SECRETS_OTP_KEY_BASE very-long-random-string Encryption key(default: default)
GITLAB_HTTPS false HTTPS(default: false)

HTTPS

The GITLAB_HTTPS flag is available only during first run.
If you started GITLAB_HTTPS with false, you will have to modify $PWD/gitlab/etc/gitlab.conf by yourself.
A config example for https enabled in nginx is at /home/git/gitlab/lib/support/nginx/gitlab-ssl.
And also run cp -pf /home/git/gitlab/lib/support/nginx/gitlab-ssl /etc/gitlab/example/gitlab.conf.example and update gitlab.

Of course you have to prepare the key pair.
Before starting gitlab container, store the key pair in the $PWD/gitlab/etc directory.

  1. $ mkdir -p ./gitlab/etc/
  2. $ cp -pf private.key ./gitlab/etc/gitlab.key
  3. $ cp -pf public.crt ./gitlab/etc/gitlab.crt

Custumize configuration files

You can modify some configuration files as preferred.
The files are stored in the $PWD/gitlab/etc directory.
You can edit with your editor normally, and then run docker restart gitlab.
These files are not modified by this container image except during the first run.
When you recreate the updated version of gitlab container image, the configuration files will be patched compared to the new one.
(If it cannot be patched due to conflict, the new container will not be started.)

Example of update conflict

The following logs shows an update conflict for database.yml. (v10.1.5 to v10.2.4)

  1. patching file /home/git/data/config/database.yml
  2. Hunk #1 FAILED at 9.
  3. Hunk #2 FAILED at 23.
  4. Hunk #3 FAILED at 33.
  5. Hunk #4 FAILED at 48.
  6. 4 out of 4 hunks FAILED -- saving rejects to file /home/git/data/config/database.yml.rej
  7. --- database.yml.example
  8. +++ database.yml.example
  9. @@ -9,4 +9,3 @@
  10. - # username: git
  11. - # password:
  12. - # host: localhost
  13. - # port: 5432
  14. + username: git
  15. + password: "secure password"
  16. + host: localhost
  17. @@ -23,2 +22,2 @@
  18. - password:
  19. - # host: localhost
  20. + password: "secure password"
  21. + host: localhost
  22. @@ -33,4 +32,4 @@
  23. - pool: 5
  24. - username: postgres
  25. - password:
  26. - # host: localhost
  27. + pool: 10
  28. + username: git
  29. + password: "secure password"
  30. + host: localhost
  31. @@ -48 +47 @@
  32. - # host: localhost
  33. + host: localhost

You would have to verify $PWD/gitlab/etc/database.yml , and then remove the example file.

  1. $ rm -f ./gitlab/config/example/database.yml.example
  2. $ docker start gitlab

Login in gitlab container for debug

If you want to log into the gitlab container, run the follow command.

  1. $ docker exec -it gitlab sh

Enjoy it!