From 9381aaf462fa3aa4a514353493149cb1fbb13c2a Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Mon, 21 Apr 2014 21:48:43 +0530 Subject: [PATCH] added support for linking to a redis container --- Changelog.md | 1 + README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ assets/init | 14 ++++++++++++-- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 79f3c660..6d748b93 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # Changelog **latest** +- added support for linking with redis container. - use sameersbn/ubuntu as the base docker image - install postgresql-client to fix restoring backups when used with a postgresql database backend. diff --git a/README.md b/README.md index 2e9bfba7..0b35f685 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ - [PostgreSQL](#postgresql) - [External PostgreSQL Server](#external-postgresql-server) - [Linking to PostgreSQL Container](#linking-to-postgresql-container) + - [Redis](#redis) + - [Internal Redis Server](#internal-redis-server) + - [External Redis Server](#external-redis-server) + - [Linking to Redis Container](#linking-to-redis-container) - [Mail](#mail) - [Putting it all together](#putting-it-all-together) - [Available Configuration Parameters](#available-configuration-parameters) @@ -348,6 +352,53 @@ docker run --name=gitlab -d --link postgresql:postgresql \ sameersbn/gitlab:latest ``` +## Redis + +### Internal Redis Server + +> **Warning** +> +> The internal redis server will soon be removed from the image. + +> Please use a linked [redis](#linking-to-redis-container) container +> or a external [redis](#external-redis-server) server + +> You've been warned. + +GitLab uses the redis server for its key-value data store. The redis server connection details can be specified using environment variables. If not specified, the starts a redis server internally, no additional configuration is required. + +### External Redis Server +The image can be configured to use an external redis server instead of starting a redis server internally. The configuration should be specified using environment variables while starting the GitLab image. + +*Assuming that the redis server host is 192.168.1.100* + +```bash +docker run --name=gitlab -i -t --rm \ + -e "REDIS_HOST=192.168.1.100" -e "REDIS_PORT=6379" \ + sameersbn/gitlab:latest +``` +### Linking to Redis Container +You can link this image with a redis container to satisfy gitlab's redis requirement. The alias of the redis server container should be set to **redisio** while linking with the gitlab image. + +To illustrate linking with a redis container, we will use the [sameersbn/redis](https://github.com/sameersbn/docker-redis) image. Please refer the [README](https://github.com/sameersbn/docker-redis/blob/master/README.md) of docker-redis for details. + +First, lets pull the redis image from the docker index. +```bash +docker pull sameersbn/redis:latest +``` + +Lets start the redis container +```bash +docker run --name=redis -d sameersbn/redis:latest +``` + +We are now ready to start the GitLab application. + +```bash +docker run --name=gitlab -d --link redis:redisio \ + sameersbn/gitlab:latest +``` + ### Mail The mail configuration should be specified using environment variables while starting the GitLab image. The configuration defaults to using gmail to send emails and requires the specification of a valid username and password to login to the gmail servers. diff --git a/assets/init b/assets/init index e5d2abb1..8ba7c6ee 100755 --- a/assets/init +++ b/assets/init @@ -14,8 +14,8 @@ GITLAB_BACKUP_EXPIRY=${GITLAB_BACKUP_EXPIRY:-} GITLAB_SHELL_SSH_PORT=${GITLAB_SHELL_SSH_PORT:-22} -REDIS_HOST=${REDIS_HOST:-localhost} -REDIS_PORT=${REDIS_PORT:-6379} +REDIS_HOST=${REDIS_HOST:-} +REDIS_PORT=${REDIS_PORT:-} UNICORN_WORKERS=${UNICORN_WORKERS:-2} UNICORN_TIMEOUT=${UNICORN_TIMEOUT:-60} @@ -49,6 +49,16 @@ LDAP_ALLOW_USERNAME_OR_EMAIL_LOGIN=${LDAP_ALLOW_USERNAME_OR_EMAIL_LOGIN:-} LDAP_BASE=${LDAP_BASE:-} LDAP_USER_FILTER=${LDAP_USER_FILTER:-} +# is a redis container linked? +if [ -n "${REDISIO_PORT_6379_TCP_ADDR}" ]; then + REDIS_HOST=${REDIS_HOST:-${REDISIO_PORT_6379_TCP_ADDR}} + REDIS_PORT=${REDIS_PORT:-${REDISIO_PORT_6379_TCP_PORT}} +fi + +# fallback to using internal redis server +REDIS_HOST=${REDIS_HOST:-localhost} +REDIS_PORT=${REDIS_PORT:-6379} + # is a mysql or postgresql database linked? # requires that the mysql or postgresql containers have exposed # port 3306 and 5432 respectively.