Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkfei <kfei@kfei.net>2014-12-17 11:53:17 +0300
committerkfei <kfei@kfei.net>2015-02-24 14:20:57 +0300
commit9338c6325263d950966e87ddb23095075f18558e (patch)
tree1905923b5439630d794830436b777d3b000bb8b7 /docker/Dockerfile
parentc8e9eac25f384ece01de756a808fffddfc578546 (diff)
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 <kfei@kfei.net>
Diffstat (limited to 'docker/Dockerfile')
-rw-r--r--docker/Dockerfile11
1 files changed, 7 insertions, 4 deletions
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"]