From 0dcc1e88a4a9a1fe4745421474fcb3e93bfb87ef Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 27 Nov 2014 15:48:19 +0100 Subject: Add Dockerfile to build an Omnibus GitLab image --- docker/Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ docker/README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ docker/gitlab.rb | 31 +++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100644 docker/gitlab.rb (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000000..b1720e15114 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,36 @@ +# Data: docker run --name gitlab_data genezys/gitlab:7.5.1 /bin/true +# Run: docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data genezys/gitlab:7.5.1 + +FROM ubuntu:14.04 +MAINTAINER Vincent Robert + +# Install required packages +RUN apt-get update -q \ + && DEBIAN_FRONTEND=noninteractive apt-get install -qy \ + openssh-server \ + wget \ + && apt-get clean + +# Download & Install GitLab +RUN TMP_FILE=$(mktemp); \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.1-omnibus.5.2.0.ci-1_amd64.deb \ + && dpkg -i $TMP_FILE \ + && rm -f $TMP_FILE + +# Manage SSHD through runit +RUN mkdir -p /opt/gitlab/sv/sshd/supervise \ + && mkfifo /opt/gitlab/sv/sshd/supervise/ok \ + && printf "#!/bin/sh\nexec 2>&1\numask 077\nexec /usr/sbin/sshd -D" > /opt/gitlab/sv/sshd/run \ + && chmod a+x /opt/gitlab/sv/sshd/run \ + && ln -s /opt/gitlab/sv/sshd /opt/gitlab/service \ + && mkdir -p /var/run/sshd + +# Expose web & ssh +EXPOSE 80 22 + +# Volume & configuration +VOLUME ["/var/opt/gitlab", "/var/log/gitlab", "/etc/gitlab"] +ADD gitlab.rb /etc/gitlab/ + +# Default is to run runit & reconfigure +CMD gitlab-ctl reconfigure > /var/log/gitlab/reconfigure.log & /opt/gitlab/embedded/bin/runsvdir-start diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000000..ca56a9b35a4 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,42 @@ +What is GitLab? +=============== + +GitLab offers git repository management, code reviews, issue tracking, activity feeds, wikis. It has LDAP/AD integration, handles 25,000 users on a single server but can also run on a highly available active/active cluster. A subscription gives you access to our support team and to GitLab Enterprise Edition that contains extra features aimed at larger organizations. + + + +![GitLab Logo](https://gitlab.com/uploads/appearance/logo/1/brand_logo-c37eb221b456bb4b472cc1084480991f.png) + + +How to use this image. +====================== + +I recommend creating a data volume container first, this will simplify migrations and backups: + + docker run --name gitlab_data genezys/gitlab:7.5.1 /bin/true + +This empty container will exist to persist as volumes the 3 directories used by GitLab, so remember not to delete it: + +- `/var/opt/gitlab` for application data +- `/var/log/gitlab` for logs +- `/etc/gitlab` for configuration + +Then run GitLab: + + docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data genezys/gitlab:7.5.1 + +You can then go to `http://localhost:8080/` (or most likely `http://192.168.59.103:8080/` if you use boot2docker). Next time, you can just use `docker start gitlab` and `docker stop gitlab`. + + +How to configure GitLab. +======================== + +This container uses the official Omnibus GitLab distribution, so all configuration is done in the unique configuration file `/etc/gitlab/gitlab.rb`. + +To access GitLab configuration, you can start a new container using the shared data volume container: + + docker run -ti --rm --volumes-from gitlab_data ubuntu vi /etc/gitlab/gitlab.rb + +**Note** that GitLab will reconfigure itself **at each container start.** You will need to restart the container to reconfigure your GitLab. + +You can find all available options in [GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration). diff --git a/docker/gitlab.rb b/docker/gitlab.rb new file mode 100644 index 00000000000..da909db01f8 --- /dev/null +++ b/docker/gitlab.rb @@ -0,0 +1,31 @@ +# External URL should be your Docker instance. +# By default, this example is the "standard" boot2docker IP. +# Always use port 80 here to force the internal nginx to bind port 80, +# even if you intend to use another port in Docker. +external_url "http://192.168.59.103/" + +# Some configuration of GitLab +# You can find more at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration +gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' +gitlab_rails['gitlab_support_email'] = 'support@example.com' +gitlab_rails['time_zone'] = 'Europe/Paris' + +# SMTP settings +# You must use an external server, the Docker container does not install an SMTP server +gitlab_rails['smtp_enable'] = true +gitlab_rails['smtp_address'] = "smtp.example.com" +gitlab_rails['smtp_port'] = 587 +gitlab_rails['smtp_user_name'] = "user" +gitlab_rails['smtp_password'] = "password" +gitlab_rails['smtp_domain'] = "example.com" +gitlab_rails['smtp_authentication'] = "plain" +gitlab_rails['smtp_enable_starttls_auto'] = true + +# Enable LDAP authentication +# gitlab_rails['ldap_enabled'] = true +# gitlab_rails['ldap_host'] = 'ldap.example.com' +# gitlab_rails['ldap_port'] = 389 +# gitlab_rails['ldap_method'] = 'plain' # 'ssl' or 'plain' +# gitlab_rails['ldap_allow_username_or_email_login'] = false +# gitlab_rails['ldap_uid'] = 'uid' +# gitlab_rails['ldap_base'] = 'ou=users,dc=example,dc=com' -- cgit v1.2.1 From 385105382b62f10ce84730ccb4f15aecea189470 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Fri, 28 Nov 2014 07:55:59 +0100 Subject: Make docker image file user agnostic, to prevent confusion over official images. --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index b1720e15114..38a48867ca9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ -# Data: docker run --name gitlab_data genezys/gitlab:7.5.1 /bin/true -# Run: docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data genezys/gitlab:7.5.1 +# Data: docker run --name gitlab_data USER/IMAGE:TAG /bin/true +# Run: docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data USER/IMAGE:TAG FROM ubuntu:14.04 MAINTAINER Vincent Robert -- cgit v1.2.1 From e08255ceea2af40f66039c7768be8de5122649f1 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Fri, 28 Nov 2014 11:13:49 +0100 Subject: Make the docker commands so that people can build their own images. --- docker/Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 38a48867ca9..70e8ad93423 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,9 @@ -# Data: docker run --name gitlab_data USER/IMAGE:TAG /bin/true -# Run: docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data USER/IMAGE:TAG +# At this moment GitLab doesn't have official Docker images. +# Build your own based on the Omnibus packages with the following commands. +# The first commands assumes you're in the GitLab repo root directory. +# Build: sudo docker build --tag gitlab_image docker/. +# Data: sudo docker run --name gitlab_data gitlab /bin/true +# Run: sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image FROM ubuntu:14.04 MAINTAINER Vincent Robert -- cgit v1.2.1 From ba955fe17403e005e9f551e3b31e3d539681f4d1 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Mon, 1 Dec 2014 11:41:30 +0100 Subject: Change gitlab to gitlab_image on data run and add tail, thanks Vincent Robert. --- docker/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 70e8ad93423..dddab4f74b5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,10 @@ # At this moment GitLab doesn't have official Docker images. # Build your own based on the Omnibus packages with the following commands. # The first commands assumes you're in the GitLab repo root directory. -# Build: sudo docker build --tag gitlab_image docker/. -# Data: sudo docker run --name gitlab_data gitlab /bin/true -# Run: sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image +# sudo docker build --tag gitlab_image docker/ +# sudo docker run --name gitlab_data gitlab_image /bin/true +# sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image +# sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/reconfigure.log FROM ubuntu:14.04 MAINTAINER Vincent Robert -- cgit v1.2.1 From 0afa07f7f07c68c74de20f5a353fba60c1752826 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 2 Dec 2014 15:19:43 +0100 Subject: Add troubleshooting section to the docker documentation. --- docker/Dockerfile | 6 +++--- docker/README.md | 8 ++++++-- docker/troubleshooting.md | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 docker/troubleshooting.md (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index dddab4f74b5..6a0b7b7976d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,7 +4,6 @@ # sudo docker build --tag gitlab_image docker/ # sudo docker run --name gitlab_data gitlab_image /bin/true # sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image -# sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/reconfigure.log FROM ubuntu:14.04 MAINTAINER Vincent Robert @@ -12,8 +11,9 @@ MAINTAINER Vincent Robert # Install required packages RUN apt-get update -q \ && DEBIAN_FRONTEND=noninteractive apt-get install -qy \ - openssh-server \ - wget \ + openssh-server \ + wget \ + vim \ && apt-get clean # Download & Install GitLab diff --git a/docker/README.md b/docker/README.md index ca56a9b35a4..b528b22336f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,7 +8,7 @@ GitLab offers git repository management, code reviews, issue tracking, activity ![GitLab Logo](https://gitlab.com/uploads/appearance/logo/1/brand_logo-c37eb221b456bb4b472cc1084480991f.png) -How to use this image. +How to use this image ====================== I recommend creating a data volume container first, this will simplify migrations and backups: @@ -28,7 +28,7 @@ Then run GitLab: You can then go to `http://localhost:8080/` (or most likely `http://192.168.59.103:8080/` if you use boot2docker). Next time, you can just use `docker start gitlab` and `docker stop gitlab`. -How to configure GitLab. +How to configure GitLab ======================== This container uses the official Omnibus GitLab distribution, so all configuration is done in the unique configuration file `/etc/gitlab/gitlab.rb`. @@ -40,3 +40,7 @@ To access GitLab configuration, you can start a new container using the shared d **Note** that GitLab will reconfigure itself **at each container start.** You will need to restart the container to reconfigure your GitLab. You can find all available options in [GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration). + +Troubleshooting +========================= +Please see the [troubleshooting](troubleshooting.md) file in this directory. diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md new file mode 100644 index 00000000000..4916d742736 --- /dev/null +++ b/docker/troubleshooting.md @@ -0,0 +1,23 @@ +# Troubleshooting + +This is to troubleshoot https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/245 +But it might contain useful commands for other cases as well. + +The configuration to add the postgres log in vim is: +postgresql['log_directory'] = '/var/log/gitlab/postgresql.log' + +# Commands + +sudo docker rm -f gitlab +sudo docker rm -f gitlab_data + +sudo docker build --tag gitlab_image docker/ +sudo docker run --name gitlab_data gitlab_image /bin/true + +sudo docker run -ti --rm --volumes-from gitlab_data ubuntu apt-get install -y vim; sudo vi /etc/gitlab/gitlab.rb + +sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image + +sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/reconfigure.log + +sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /var/log/gitlab/postgresql.log -- cgit v1.2.1 From 40e80dbeb5d767a8a1f3142963f670fbad3ecf4c Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 2 Dec 2014 16:18:32 +0100 Subject: Remove vim since it is of no use to running GitLab. --- docker/Dockerfile | 1 - 1 file changed, 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 6a0b7b7976d..292a7238d61 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,7 +13,6 @@ RUN apt-get update -q \ && DEBIAN_FRONTEND=noninteractive apt-get install -qy \ openssh-server \ wget \ - vim \ && apt-get clean # Download & Install GitLab -- cgit v1.2.1 From 8dd3a16227149405f2e38663c16099b53db1745d Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 2 Dec 2014 16:24:55 +0100 Subject: Change vim command. --- docker/troubleshooting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md index 4916d742736..1d80473c7c2 100644 --- a/docker/troubleshooting.md +++ b/docker/troubleshooting.md @@ -14,7 +14,7 @@ sudo docker rm -f gitlab_data sudo docker build --tag gitlab_image docker/ sudo docker run --name gitlab_data gitlab_image /bin/true -sudo docker run -ti --rm --volumes-from gitlab_data ubuntu apt-get install -y vim; sudo vi /etc/gitlab/gitlab.rb +sudo docker run -ti --rm --volumes-from gitlab_data ubuntu apt-get update && sudo apt-get install -y vim && sudo vim /etc/gitlab/gitlab.rb sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image -- cgit v1.2.1 From a33cb855302f189f3510fc2fbe73851d9d7a7b74 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 2 Dec 2014 16:28:12 +0100 Subject: Add interactive commands. --- docker/troubleshooting.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docker') diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md index 1d80473c7c2..415c8f785c0 100644 --- a/docker/troubleshooting.md +++ b/docker/troubleshooting.md @@ -21,3 +21,5 @@ sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --vol sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/reconfigure.log sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /var/log/gitlab/postgresql.log + +sudo docker run -ti --rm --volumes-from gitlab_data ubuntu /bin/sh -- cgit v1.2.1 From 6f9d9ea09ead63bbed43b94f57edf5e05ade661c Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 2 Dec 2014 16:57:52 +0100 Subject: Postgres log location is a directory. --- docker/troubleshooting.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docker') diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md index 415c8f785c0..e2717a13b4a 100644 --- a/docker/troubleshooting.md +++ b/docker/troubleshooting.md @@ -4,7 +4,7 @@ This is to troubleshoot https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2 But it might contain useful commands for other cases as well. The configuration to add the postgres log in vim is: -postgresql['log_directory'] = '/var/log/gitlab/postgresql.log' +postgresql['log_directory'] = '/var/log/gitlab/postgresql' # Commands @@ -20,6 +20,6 @@ sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --vol sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/reconfigure.log -sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /var/log/gitlab/postgresql.log +sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/postgresql/current sudo docker run -ti --rm --volumes-from gitlab_data ubuntu /bin/sh -- cgit v1.2.1 From 3b643bc87ba126e00550e6a067e4327020452a1b Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 2 Dec 2014 17:16:46 +0100 Subject: Move build to first step and add interactive commands. --- docker/troubleshooting.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md index e2717a13b4a..deab144841c 100644 --- a/docker/troubleshooting.md +++ b/docker/troubleshooting.md @@ -8,10 +8,12 @@ postgresql['log_directory'] = '/var/log/gitlab/postgresql' # Commands +```bash +sudo docker build --tag gitlab_image docker/ + sudo docker rm -f gitlab sudo docker rm -f gitlab_data -sudo docker build --tag gitlab_image docker/ sudo docker run --name gitlab_data gitlab_image /bin/true sudo docker run -ti --rm --volumes-from gitlab_data ubuntu apt-get update && sudo apt-get install -y vim && sudo vim /etc/gitlab/gitlab.rb @@ -23,3 +25,27 @@ sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitla sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/postgresql/current sudo docker run -ti --rm --volumes-from gitlab_data ubuntu /bin/sh +``` + +# Interactively + +```bash +# First start a GitLab container without starting GitLab +# This is almost the same as starting the GitLab container except: +# - we run interactively (-t -i) +# - we define TERM=linux because it allows to use arrow keys in vi (!!!) +# - we choose another startup command (bash) +sudo docker run -ti -e TERM=linux --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image bash + +# Configure GitLab to redirect PostgreSQL logs +echo "postgresql['log_directory'] = '/var/log/gitlab/postgresql'" >> /etc/gitlab/gitlab.rb + +# You can now start GitLab manually from Bash (in the background) +gitlab-ctl reconfigure > /var/log/gitlab/reconfigure.log & /opt/gitlab/embedded/bin/runsvdir-start & + +# And tail the logs (PostgreSQL log may not exist immediately) +tail -f /var/log/gitlab/reconfigure.log /var/log/gitlab/postgresql/current + +# And get the memory +cat /proc/meminfo +``` -- cgit v1.2.1 From ed7760b1d7b58d07793437db78f960ed7c4ae182 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 2 Dec 2014 19:25:04 +0100 Subject: Add command to limit Postgres memory allocation, thanks Jacob. --- docker/troubleshooting.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docker') diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md index deab144841c..442cc69ec58 100644 --- a/docker/troubleshooting.md +++ b/docker/troubleshooting.md @@ -40,7 +40,11 @@ sudo docker run -ti -e TERM=linux --name gitlab --publish 8080:80 --publish 2222 # Configure GitLab to redirect PostgreSQL logs echo "postgresql['log_directory'] = '/var/log/gitlab/postgresql'" >> /etc/gitlab/gitlab.rb +# Prevent Postgres from allocating 25% of total memory +echo "postgresql['shared_buffers'] = '100MB'" >> /etc/gitlab/gitlab.rb + # You can now start GitLab manually from Bash (in the background) +# Maybe the command below is still missing something to run in the background gitlab-ctl reconfigure > /var/log/gitlab/reconfigure.log & /opt/gitlab/embedded/bin/runsvdir-start & # And tail the logs (PostgreSQL log may not exist immediately) -- cgit v1.2.1 From 9e4d39c0513fc91fc2c844d482e82a8e9df8927d Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Wed, 3 Dec 2014 12:41:47 +0100 Subject: Move commands to the readme, rename gitlab to gitlab_app, add PostgreSQL tweaks to gitlab.rb. --- docker/Dockerfile | 7 ------- docker/README.md | 30 +++++++++++++++++++++++------- docker/gitlab.rb | 6 ++++++ docker/troubleshooting.md | 18 +++++++++++++----- 4 files changed, 42 insertions(+), 19 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 292a7238d61..3ffedd16e81 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,10 +1,3 @@ -# At this moment GitLab doesn't have official Docker images. -# Build your own based on the Omnibus packages with the following commands. -# The first commands assumes you're in the GitLab repo root directory. -# sudo docker build --tag gitlab_image docker/ -# sudo docker run --name gitlab_data gitlab_image /bin/true -# sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image - FROM ubuntu:14.04 MAINTAINER Vincent Robert diff --git a/docker/README.md b/docker/README.md index b528b22336f..a2a194bd42c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -11,21 +11,37 @@ GitLab offers git repository management, code reviews, issue tracking, activity How to use this image ====================== -I recommend creating a data volume container first, this will simplify migrations and backups: +At this moment GitLab doesn't have official Docker images. +Build your own based on the Omnibus packages with the following command (it assumes you're in the GitLab repo root directory): - docker run --name gitlab_data genezys/gitlab:7.5.1 /bin/true +```bash +sudo docker build --tag gitlab_image docker/ +``` -This empty container will exist to persist as volumes the 3 directories used by GitLab, so remember not to delete it: +We assume using a data volume container, this will simplify migrations and backups. +This empty container will exist to persist as volumes the 3 directories used by GitLab, so remember not to delete it. + +The directories on data container are: - `/var/opt/gitlab` for application data - `/var/log/gitlab` for logs - `/etc/gitlab` for configuration -Then run GitLab: +Create the data container with: + +```bash +sudo docker run --name gitlab_data gitlab_image /bin/true +``` + +After creating this run GitLab: + +```bash +sudo docker run --detach --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image +``` - docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data genezys/gitlab:7.5.1 +It might take a while before the docker container is responding to queries. -You can then go to `http://localhost:8080/` (or most likely `http://192.168.59.103:8080/` if you use boot2docker). Next time, you can just use `docker start gitlab` and `docker stop gitlab`. +You can then go to `http://localhost:8080/` (or `http://192.168.59.103:8080/` if you use boot2docker). Next time, you can just use `sudo docker start gitlab_app` and `sudo docker stop gitlab_app`. How to configure GitLab @@ -39,7 +55,7 @@ To access GitLab configuration, you can start a new container using the shared d **Note** that GitLab will reconfigure itself **at each container start.** You will need to restart the container to reconfigure your GitLab. -You can find all available options in [GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration). +You can find all available options in [Omnibus GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration). Troubleshooting ========================= diff --git a/docker/gitlab.rb b/docker/gitlab.rb index da909db01f8..7fddf309c01 100644 --- a/docker/gitlab.rb +++ b/docker/gitlab.rb @@ -4,6 +4,12 @@ # even if you intend to use another port in Docker. external_url "http://192.168.59.103/" +# Prevent Postgres from trying to allocate 25% of total memory +postgresql['shared_buffers'] = '1MB' + +# Configure GitLab to redirect PostgreSQL logs to the data volume +postgresql['log_directory'] = '/var/log/gitlab/postgresql' + # Some configuration of GitLab # You can find more at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md index 442cc69ec58..b1b70de5997 100644 --- a/docker/troubleshooting.md +++ b/docker/troubleshooting.md @@ -11,20 +11,22 @@ postgresql['log_directory'] = '/var/log/gitlab/postgresql' ```bash sudo docker build --tag gitlab_image docker/ -sudo docker rm -f gitlab +sudo docker rm -f gitlab_app sudo docker rm -f gitlab_data sudo docker run --name gitlab_data gitlab_image /bin/true sudo docker run -ti --rm --volumes-from gitlab_data ubuntu apt-get update && sudo apt-get install -y vim && sudo vim /etc/gitlab/gitlab.rb -sudo docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image +sudo docker run --detach --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/reconfigure.log sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/postgresql/current -sudo docker run -ti --rm --volumes-from gitlab_data ubuntu /bin/sh +sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /var/opt/gitlab/postgresql/data/postgresql.conf | grep shared_buffers + +sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /etc/gitlab/gitlab.rb ``` # Interactively @@ -35,21 +37,27 @@ sudo docker run -ti --rm --volumes-from gitlab_data ubuntu /bin/sh # - we run interactively (-t -i) # - we define TERM=linux because it allows to use arrow keys in vi (!!!) # - we choose another startup command (bash) -sudo docker run -ti -e TERM=linux --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image bash +sudo docker run -ti -e TERM=linux --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image bash # Configure GitLab to redirect PostgreSQL logs echo "postgresql['log_directory'] = '/var/log/gitlab/postgresql'" >> /etc/gitlab/gitlab.rb # Prevent Postgres from allocating 25% of total memory -echo "postgresql['shared_buffers'] = '100MB'" >> /etc/gitlab/gitlab.rb +echo "postgresql['shared_buffers'] = '1MB'" >> /etc/gitlab/gitlab.rb # You can now start GitLab manually from Bash (in the background) # Maybe the command below is still missing something to run in the background gitlab-ctl reconfigure > /var/log/gitlab/reconfigure.log & /opt/gitlab/embedded/bin/runsvdir-start & +# Inspect PostgreSQL config +cat /var/opt/gitlab/postgresql/data/postgresql.conf | grep shared_buffers + # And tail the logs (PostgreSQL log may not exist immediately) tail -f /var/log/gitlab/reconfigure.log /var/log/gitlab/postgresql/current # And get the memory cat /proc/meminfo +head /proc/sys/kernel/shmmax /proc/sys/kernel/shmall +free -m + ``` -- cgit v1.2.1 From 3838b168b33163d4cbe64b7ff6e6b408bc8d857f Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Wed, 3 Dec 2014 12:43:26 +0100 Subject: Add password hint. --- docker/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/README.md b/docker/README.md index a2a194bd42c..a489203d017 100644 --- a/docker/README.md +++ b/docker/README.md @@ -41,7 +41,9 @@ sudo docker run --detach --name gitlab_app --publish 8080:80 --publish 2222:22 - It might take a while before the docker container is responding to queries. -You can then go to `http://localhost:8080/` (or `http://192.168.59.103:8080/` if you use boot2docker). Next time, you can just use `sudo docker start gitlab_app` and `sudo docker stop gitlab_app`. +You can then go to `http://localhost:8080/` (or `http://192.168.59.103:8080/` if you use boot2docker). +You can login with username `root` and password `5iveL!fe`. +Next time, you can just use `sudo docker start gitlab_app` and `sudo docker stop gitlab_app`. How to configure GitLab -- cgit v1.2.1 From 2a0ee91f7ca3008d6bbdd10a7351485d1fa0468f Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Wed, 3 Dec 2014 14:07:18 +0100 Subject: Remove docker file maintainer at his request. https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/245#note_647506 --- docker/Dockerfile | 1 - 1 file changed, 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 3ffedd16e81..d0b5338773e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,4 @@ FROM ubuntu:14.04 -MAINTAINER Vincent Robert # Install required packages RUN apt-get update -q \ -- cgit v1.2.1 From d7aff11876f517d9e9cb4eb2237ceed4211d7013 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 4 Dec 2014 10:30:10 +0100 Subject: Move to 7.5.2 --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index d0b5338773e..93c564fc03b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update -q \ # Download & Install GitLab RUN TMP_FILE=$(mktemp); \ - wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.1-omnibus.5.2.0.ci-1_amd64.deb \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.2-omnibus.5.2.1.ci-1_amd64.deb \ && dpkg -i $TMP_FILE \ && rm -f $TMP_FILE -- cgit v1.2.1 From 58b58fe44b0924ce24f2f3e5d63b0f99fcf22f9f Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 4 Dec 2014 10:38:04 +0100 Subject: gitlab-ctl can now be followed with docker logs --- docker/Dockerfile | 2 +- docker/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 93c564fc03b..e9b7883e983 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -29,4 +29,4 @@ VOLUME ["/var/opt/gitlab", "/var/log/gitlab", "/etc/gitlab"] ADD gitlab.rb /etc/gitlab/ # Default is to run runit & reconfigure -CMD gitlab-ctl reconfigure > /var/log/gitlab/reconfigure.log & /opt/gitlab/embedded/bin/runsvdir-start +CMD gitlab-ctl reconfigure & /opt/gitlab/embedded/bin/runsvdir-start diff --git a/docker/README.md b/docker/README.md index a489203d017..e66278632f7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -39,7 +39,7 @@ After creating this run GitLab: sudo docker run --detach --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image ``` -It might take a while before the docker container is responding to queries. +It might take a while before the docker container is responding to queries. You can follow the configuration process with `docker logs -f gitlab`. You can then go to `http://localhost:8080/` (or `http://192.168.59.103:8080/` if you use boot2docker). You can login with username `root` and password `5iveL!fe`. -- cgit v1.2.1 From 176105eca628b297fbfc20b29146f2a8d5ddd74d Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 4 Dec 2014 10:38:35 +0100 Subject: Reword configuration to recommend an interactive command line --- docker/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'docker') diff --git a/docker/README.md b/docker/README.md index e66278632f7..1fbf703e25c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -51,14 +51,18 @@ How to configure GitLab This container uses the official Omnibus GitLab distribution, so all configuration is done in the unique configuration file `/etc/gitlab/gitlab.rb`. -To access GitLab configuration, you can start a new container using the shared data volume container: +To access GitLab configuration, you can start an interactive command line in a new container using the shared data volume container, you will be able to browse the 3 directories and use your favorite text editor: - docker run -ti --rm --volumes-from gitlab_data ubuntu vi /etc/gitlab/gitlab.rb +```bash +docker run -ti -e TERM=linux --rm --volumes-from gitlab_data ubuntu +vi /etc/gitlab/gitlab.rb +``` **Note** that GitLab will reconfigure itself **at each container start.** You will need to restart the container to reconfigure your GitLab. You can find all available options in [Omnibus GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration). + Troubleshooting ========================= Please see the [troubleshooting](troubleshooting.md) file in this directory. -- cgit v1.2.1 From 14a1c1b4e6393dab2bd4c691a7241810980c0623 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Thu, 4 Dec 2014 11:03:40 +0100 Subject: Add some comments about updating the Omnibus package download location for the docker image. --- docker/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index d0b5338773e..7d538cc5e93 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,6 +8,8 @@ RUN apt-get update -q \ && apt-get clean # Download & Install GitLab +# If the Omnibus package version below is outdates please contribute a merge request to update it. +# If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.1-omnibus.5.2.0.ci-1_amd64.deb \ && dpkg -i $TMP_FILE \ -- cgit v1.2.1 From a3e9046ad522d4d234c9b4e644a1175f9ed8213d Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Thu, 4 Dec 2014 12:29:30 +0100 Subject: Fix spelling error in dockerfile, thanks Vincent for noting it. --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index a7b44d823ea..aea59916c7a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update -q \ && apt-get clean # Download & Install GitLab -# If the Omnibus package version below is outdates please contribute a merge request to update it. +# If the Omnibus package version below is outdated please contribute a merge request to update it. # If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.2-omnibus.5.2.1.ci-1_amd64.deb \ -- cgit v1.2.1 From 4acf25169336b9d7a20782d5ad954a40db8764e0 Mon Sep 17 00:00:00 2001 From: zertrin Date: Thu, 4 Dec 2014 15:58:08 +0100 Subject: Fix typo in the README.md for docker The container name has been previously renamed to "gitlab_app". --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/README.md b/docker/README.md index 1fbf703e25c..58982a238a8 100644 --- a/docker/README.md +++ b/docker/README.md @@ -39,7 +39,7 @@ After creating this run GitLab: sudo docker run --detach --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image ``` -It might take a while before the docker container is responding to queries. You can follow the configuration process with `docker logs -f gitlab`. +It might take a while before the docker container is responding to queries. You can follow the configuration process with `docker logs -f gitlab_app`. You can then go to `http://localhost:8080/` (or `http://192.168.59.103:8080/` if you use boot2docker). You can login with username `root` and password `5iveL!fe`. -- cgit v1.2.1 From c981d693380e5c5c0b66aa654e63cf653f1e5f42 Mon Sep 17 00:00:00 2001 From: kfei Date: Tue, 16 Dec 2014 09:04:52 -0800 Subject: Update the Omnibus package in Dockerfile From 7.5.2 to 7.5.3. Signed-off-by: kfei --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index aea59916c7a..41514e76687 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update -q \ # If the Omnibus package version below is outdated please contribute a merge request to update it. # If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ - wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.2-omnibus.5.2.1.ci-1_amd64.deb \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.3-omnibus.5.2.1.ci-1_amd64.deb \ && dpkg -i $TMP_FILE \ && rm -f $TMP_FILE -- cgit v1.2.1 From e9f974dc12cb7ab37f1fc089f0525bd491572a5c Mon Sep 17 00:00:00 2001 From: kfei Date: Tue, 16 Dec 2014 22:11:50 -0800 Subject: Reduce the size of Docker image 1) Add `--no-install-recommends` option to `apt-get install`, this avoids lots of (~30MB) unnecessary packages. 2) Add `ca-certificates` package for `wget` fetching stuffs from Amazon S3. 3) There is no need to run `apt-get clean` for an image derived from official Ubuntu since they already cleaned (see also: http://goo.gl/B2SQRB) all the garbages produced by `apt-get`. Signed-off-by: kfei --- docker/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index aea59916c7a..2cc01f24098 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,10 +2,10 @@ FROM ubuntu:14.04 # Install required packages RUN apt-get update -q \ - && DEBIAN_FRONTEND=noninteractive apt-get install -qy \ + && DEBIAN_FRONTEND=noninteractive apt-get install -qy --no-install-recommends \ + ca-certificates \ openssh-server \ - wget \ - && apt-get clean + wget # Download & Install GitLab # If the Omnibus package version below is outdated please contribute a merge request to update it. -- cgit v1.2.1 From 210a13ad425d14eceacd902407c2ee3f2801ac32 Mon Sep 17 00:00:00 2001 From: kfei Date: Thu, 15 Jan 2015 11:34:49 +0800 Subject: Update the Omnibus package in Dockerfile From 7.5.3 to 7.6.2. Signed-off-by: kfei --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 5d0880b8c88..445fdd6d063 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update -q \ # If the Omnibus package version below is outdated please contribute a merge request to update it. # If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ - wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.5.3-omnibus.5.2.1.ci-1_amd64.deb \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.6.2-omnibus.5.3.0.ci.1-1_amd64.deb \ && dpkg -i $TMP_FILE \ && rm -f $TMP_FILE -- cgit v1.2.1 From 35bf471a13abe0ec68ca8ceb19f896be5ce63c46 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 29 Jan 2015 16:34:01 +0100 Subject: Bump Gitlab for Docker to 7.7.1 --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 445fdd6d063..70d6c721f1c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update -q \ # If the Omnibus package version below is outdated please contribute a merge request to update it. # If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ - wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.6.2-omnibus.5.3.0.ci.1-1_amd64.deb \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.1-omnibus.5.4.1.ci-1_amd64.deb \ && dpkg -i $TMP_FILE \ && rm -f $TMP_FILE -- cgit v1.2.1 From a7a45dc949b9475dff674be57e8d3a7aa8811857 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Fri, 30 Jan 2015 22:29:41 +0100 Subject: Bump GitLab for Docker to version 7.7.2 --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index 70d6c721f1c..ec0923bd4c7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update -q \ # If the Omnibus package version below is outdated please contribute a merge request to update it. # If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ - wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.1-omnibus.5.4.1.ci-1_amd64.deb \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.2-omnibus.5.4.2.ci-1_amd64.deb \ && dpkg -i $TMP_FILE \ && rm -f $TMP_FILE -- cgit v1.2.1 From e23110e6f158608c75e4c661fd57a4bb9c96334a Mon Sep 17 00:00:00 2001 From: shafan Date: Mon, 23 Feb 2015 14:08:46 +0000 Subject: Bump GitLab for Docker to version 7.8.0 --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docker') diff --git a/docker/Dockerfile b/docker/Dockerfile index ec0923bd4c7..cfb89357a67 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update -q \ # If the Omnibus package version below is outdated please contribute a merge request to update it. # If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ - wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.2-omnibus.5.4.2.ci-1_amd64.deb \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.8.0-omnibus-1_amd64.deb \ && dpkg -i $TMP_FILE \ && rm -f $TMP_FILE @@ -31,4 +31,4 @@ VOLUME ["/var/opt/gitlab", "/var/log/gitlab", "/etc/gitlab"] ADD gitlab.rb /etc/gitlab/ # Default is to run runit & reconfigure -CMD gitlab-ctl reconfigure & /opt/gitlab/embedded/bin/runsvdir-start +CMD gitlab-ctl reconfigure & /opt/gitlab/embedded/bin/runsvdir-start \ No newline at end of file -- cgit v1.2.1 From 9338c6325263d950966e87ddb23095075f18558e Mon Sep 17 00:00:00 2001 From: kfei Date: Wed, 17 Dec 2014 00:53:17 -0800 Subject: Gracefully shutdown services in Docker container The problem is `docker stop` only sends SIGTERM to the PID 1 inside the container, and the PID 1 (`/bin/sh -c ...`) does not take care of signals. Hence the services (e.g., postgresql, redis, sidekiq, etc) never have chances to graceful shutdown. Docker just kills the container after its 10 seconds timeout by default. What this commit does: 1) Add a wrapper as the default executable of Docker container. Which starts services through `runit`, reconfigure Gitlab by `gitlab-ctl` and gracefully shutdown all services when a SIGTERM is received. 2) Create an `assets` directory for assets. 3) Add `.dockerignore` file. Now you'll see the following log messages after `docker stop`: ``` SIGTERM signal received, try to gracefully shutdown all services... ok: down: logrotate: 1s, normally up ok: down: nginx: 0s, normally up ok: down: postgresql: 1s, normally up ok: down: redis: 0s, normally up ok: down: sidekiq: 0s, normally up ok: down: unicorn: 0s, normally up ``` Signed-off-by: kfei --- docker/.dockerignore | 1 + docker/Dockerfile | 11 +++++++---- docker/assets/gitlab.rb | 37 +++++++++++++++++++++++++++++++++++++ docker/assets/wrapper | 17 +++++++++++++++++ docker/gitlab.rb | 37 ------------------------------------- 5 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 docker/.dockerignore create mode 100644 docker/assets/gitlab.rb create mode 100755 docker/assets/wrapper delete mode 100644 docker/gitlab.rb (limited to 'docker') diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 00000000000..dd449725e18 --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1 @@ +*.md diff --git a/docker/Dockerfile b/docker/Dockerfile index cfb89357a67..3a0a55e18e3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -26,9 +26,12 @@ RUN mkdir -p /opt/gitlab/sv/sshd/supervise \ # Expose web & ssh EXPOSE 80 22 -# Volume & configuration +# Declare volumes VOLUME ["/var/opt/gitlab", "/var/log/gitlab", "/etc/gitlab"] -ADD gitlab.rb /etc/gitlab/ -# Default is to run runit & reconfigure -CMD gitlab-ctl reconfigure & /opt/gitlab/embedded/bin/runsvdir-start \ No newline at end of file +# Copy assets +COPY assets/gitlab.rb /etc/gitlab/ +COPY assets/wrapper /usr/local/bin/ + +# Wrapper to handle signal, trigger runit and reconfigure GitLab +CMD ["/usr/local/bin/wrapper"] diff --git a/docker/assets/gitlab.rb b/docker/assets/gitlab.rb new file mode 100644 index 00000000000..7fddf309c01 --- /dev/null +++ b/docker/assets/gitlab.rb @@ -0,0 +1,37 @@ +# External URL should be your Docker instance. +# By default, this example is the "standard" boot2docker IP. +# Always use port 80 here to force the internal nginx to bind port 80, +# even if you intend to use another port in Docker. +external_url "http://192.168.59.103/" + +# Prevent Postgres from trying to allocate 25% of total memory +postgresql['shared_buffers'] = '1MB' + +# Configure GitLab to redirect PostgreSQL logs to the data volume +postgresql['log_directory'] = '/var/log/gitlab/postgresql' + +# Some configuration of GitLab +# You can find more at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration +gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' +gitlab_rails['gitlab_support_email'] = 'support@example.com' +gitlab_rails['time_zone'] = 'Europe/Paris' + +# SMTP settings +# You must use an external server, the Docker container does not install an SMTP server +gitlab_rails['smtp_enable'] = true +gitlab_rails['smtp_address'] = "smtp.example.com" +gitlab_rails['smtp_port'] = 587 +gitlab_rails['smtp_user_name'] = "user" +gitlab_rails['smtp_password'] = "password" +gitlab_rails['smtp_domain'] = "example.com" +gitlab_rails['smtp_authentication'] = "plain" +gitlab_rails['smtp_enable_starttls_auto'] = true + +# Enable LDAP authentication +# gitlab_rails['ldap_enabled'] = true +# gitlab_rails['ldap_host'] = 'ldap.example.com' +# gitlab_rails['ldap_port'] = 389 +# gitlab_rails['ldap_method'] = 'plain' # 'ssl' or 'plain' +# gitlab_rails['ldap_allow_username_or_email_login'] = false +# gitlab_rails['ldap_uid'] = 'uid' +# gitlab_rails['ldap_base'] = 'ou=users,dc=example,dc=com' diff --git a/docker/assets/wrapper b/docker/assets/wrapper new file mode 100755 index 00000000000..9e6e7a05903 --- /dev/null +++ b/docker/assets/wrapper @@ -0,0 +1,17 @@ +#!/bin/bash + +function sigterm_handler() { + echo "SIGTERM signal received, try to gracefully shutdown all services..." + gitlab-ctl stop +} + +trap "sigterm_handler; exit" TERM + +function entrypoint() { + # Default is to run runit and reconfigure GitLab + gitlab-ctl reconfigure & + /opt/gitlab/embedded/bin/runsvdir-start & + wait +} + +entrypoint diff --git a/docker/gitlab.rb b/docker/gitlab.rb deleted file mode 100644 index 7fddf309c01..00000000000 --- a/docker/gitlab.rb +++ /dev/null @@ -1,37 +0,0 @@ -# External URL should be your Docker instance. -# By default, this example is the "standard" boot2docker IP. -# Always use port 80 here to force the internal nginx to bind port 80, -# even if you intend to use another port in Docker. -external_url "http://192.168.59.103/" - -# Prevent Postgres from trying to allocate 25% of total memory -postgresql['shared_buffers'] = '1MB' - -# Configure GitLab to redirect PostgreSQL logs to the data volume -postgresql['log_directory'] = '/var/log/gitlab/postgresql' - -# Some configuration of GitLab -# You can find more at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration -gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' -gitlab_rails['gitlab_support_email'] = 'support@example.com' -gitlab_rails['time_zone'] = 'Europe/Paris' - -# SMTP settings -# You must use an external server, the Docker container does not install an SMTP server -gitlab_rails['smtp_enable'] = true -gitlab_rails['smtp_address'] = "smtp.example.com" -gitlab_rails['smtp_port'] = 587 -gitlab_rails['smtp_user_name'] = "user" -gitlab_rails['smtp_password'] = "password" -gitlab_rails['smtp_domain'] = "example.com" -gitlab_rails['smtp_authentication'] = "plain" -gitlab_rails['smtp_enable_starttls_auto'] = true - -# Enable LDAP authentication -# gitlab_rails['ldap_enabled'] = true -# gitlab_rails['ldap_host'] = 'ldap.example.com' -# gitlab_rails['ldap_port'] = 389 -# gitlab_rails['ldap_method'] = 'plain' # 'ssl' or 'plain' -# gitlab_rails['ldap_allow_username_or_email_login'] = false -# gitlab_rails['ldap_uid'] = 'uid' -# gitlab_rails['ldap_base'] = 'ou=users,dc=example,dc=com' -- cgit v1.2.1