Skip to content

Commit 5e2d801

Browse files
author
Sameer Naik
committed
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.
1 parent 46ea17f commit 5e2d801

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ build:
1616
start:
1717
@echo "Starting gitlab..."
1818
@docker run --name='gitlab-demo' -d \
19-
-p 10022:22 -p 10080:80 \
2019
-e 'GITLAB_PORT=10080' -e 'GITLAB_SSH_PORT=10022' \
20+
-p 10022:22 -p 10080:80 \
21+
-v /var/run/docker.sock:/run/docker.sock \
22+
-v $(shell which docker):/bin/docker \
2123
${USER}/gitlab:latest >/dev/null
2224
@echo "GitLab instance is booting up..."
2325
@echo "Please be patient. This could take a while..."

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ Run the gitlab image
153153

154154
```bash
155155
docker run --name='gitlab' -it --rm \
156-
-p 10022:22 -p 10080:80 \
157156
-e 'GITLAB_PORT=10080' -e 'GITLAB_SSH_PORT=10022' \
157+
-p 10022:22 -p 10080:80 \
158+
-v /var/run/docker.sock:/run/docker.sock \
159+
-v $(which docker):/bin/docker \
158160
sameersbn/gitlab:7.2.2
159161
```
160162

assets/init

+27
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,33 @@ case "${DB_TYPE}" in
135135
*) echo "Unsupported database adapter. Available adapters are mysql and postgres." && exit 1 ;;
136136
esac
137137

138+
##
139+
## For the sake of getting the quick start guide to work,
140+
## we attempt to spin up a redis container if possible.
141+
##
142+
## NOTE: this is only meant for getting the quick start guide to work .
143+
##
144+
if [ -z "${REDIS_HOST}" -a -n "$(which docker)" -a -S /var/run/docker.sock ]; then
145+
echo "Redis connection details not specified."
146+
echo "Will try to spin up a new redis image with the name redis-gitlab."
147+
echo "Please manually configure the redis connection in production."
148+
case "$(docker inspect --format {{.State.Running}} redis-gitlab 2>/dev/null)" in
149+
true)
150+
echo "Using existing redis container..."
151+
;;
152+
false)
153+
echo "Starting up existing redis container..."
154+
docker start redis-gitlab >/dev/null 2>/dev/null
155+
;;
156+
*)
157+
echo "Starting up a new redis container..."
158+
docker run --name='redis-gitlab' -d sameersbn/redis:latest >/dev/null 2>/dev/null
159+
;;
160+
esac
161+
REDIS_HOST=$(docker inspect --format {{.NetworkSettings.IPAddress}} redis-gitlab 2>/dev/null)
162+
REDIS_PORT=6379
163+
fi
164+
138165
if [ -z "${REDIS_HOST}" ]; then
139166
echo "ERROR: "
140167
echo " Please configure the redis connection."

0 commit comments

Comments
 (0)