From 5e2d8014bef9f4d772d9d096f4e8d004d8def674 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Sat, 20 Sep 2014 14:43:14 +0530 Subject: [PATCH] launch a redis container if we can connect to the host docker When the redis connection parameters are not specified, the image will try to spin up a redis container if it is able to communicate with the host docker. This is only possible if the following two options are specified in the docker run command: `-v /var/run/docker.sock:/run/docker.sock` `-v $(which docker):/bin/docker` This is primarily added to get the quick start guide to work without much of a hassel. --- Makefile | 4 +++- README.md | 4 +++- assets/init | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9063b55e..fd662693 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,10 @@ build: start: @echo "Starting gitlab..." @docker run --name='gitlab-demo' -d \ - -p 10022:22 -p 10080:80 \ -e 'GITLAB_PORT=10080' -e 'GITLAB_SSH_PORT=10022' \ + -p 10022:22 -p 10080:80 \ + -v /var/run/docker.sock:/run/docker.sock \ + -v $(shell which docker):/bin/docker \ ${USER}/gitlab:latest >/dev/null @echo "GitLab instance is booting up..." @echo "Please be patient. This could take a while..." diff --git a/README.md b/README.md index 4d7fd00a..88d4f497 100644 --- a/README.md +++ b/README.md @@ -153,8 +153,10 @@ Run the gitlab image ```bash docker run --name='gitlab' -it --rm \ --p 10022:22 -p 10080:80 \ -e 'GITLAB_PORT=10080' -e 'GITLAB_SSH_PORT=10022' \ +-p 10022:22 -p 10080:80 \ +-v /var/run/docker.sock:/run/docker.sock \ +-v $(which docker):/bin/docker \ sameersbn/gitlab:7.2.2 ``` diff --git a/assets/init b/assets/init index ebfcd75a..52eae04b 100755 --- a/assets/init +++ b/assets/init @@ -135,6 +135,33 @@ case "${DB_TYPE}" in *) echo "Unsupported database adapter. Available adapters are mysql and postgres." && exit 1 ;; esac +## +## For the sake of getting the quick start guide to work, +## we attempt to spin up a redis container if possible. +## +## NOTE: this is only meant for getting the quick start guide to work . +## +if [ -z "${REDIS_HOST}" -a -n "$(which docker)" -a -S /var/run/docker.sock ]; then + echo "Redis connection details not specified." + echo "Will try to spin up a new redis image with the name redis-gitlab." + echo "Please manually configure the redis connection in production." + case "$(docker inspect --format {{.State.Running}} redis-gitlab 2>/dev/null)" in + true) + echo "Using existing redis container..." + ;; + false) + echo "Starting up existing redis container..." + docker start redis-gitlab >/dev/null 2>/dev/null + ;; + *) + echo "Starting up a new redis container..." + docker run --name='redis-gitlab' -d sameersbn/redis:latest >/dev/null 2>/dev/null + ;; + esac + REDIS_HOST=$(docker inspect --format {{.NetworkSettings.IPAddress}} redis-gitlab 2>/dev/null) + REDIS_PORT=6379 +fi + if [ -z "${REDIS_HOST}" ]; then echo "ERROR: " echo " Please configure the redis connection."