Skip to content

Commit acfa96b

Browse files
author
Sameer Naik
committed
Merge branch 'remove-internal-redis'
Refer #39 Refer #149
2 parents 71d8237 + 5e2d801 commit acfa96b

File tree

6 files changed

+74
-40
lines changed

6 files changed

+74
-40
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
**latest**
4+
- removed internal redis server
45
- shutdown the container gracefully
56

67
**7.2.2**

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MAINTAINER sameer@damagehead.com
33

44
RUN apt-get update \
55
&& apt-get install -y supervisor logrotate locales \
6-
nginx openssh-server mysql-server redis-server \
6+
nginx openssh-server mysql-server redis-tools \
77
git-core postgresql-client ruby rubygems \
88
python2.7 python-docutils \
99
libmysqlclient18 libpq5 zlib1g libyaml-0-2 libssl1.0.0 \

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

+33-17
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

@@ -203,13 +205,25 @@ GitLab uses a database backend to store its data. You can configure this image t
203205
> **Warning**
204206
>
205207
> The internal mysql server will soon be removed from the image.
206-
207-
> Please use a linked [mysql](#linking-to-mysql-container) or
208-
> [postgresql](#linking-to-postgresql-container) container instead.
209-
> Or else connect with an external [mysql](#external-mysql-server) or
210-
> [postgresql](#external-postgresql-server) server.
211-
212-
> You've been warned.
208+
>
209+
> Please use a [linked mysql](#linking-to-mysql-container) container or specify a connection to a [external mysql](#external-mysql-server) server.
210+
>
211+
> **You've been warned.**
212+
>
213+
> If you are already using the internal mysql server then follow these instructions to migrate to a linked mysql container:
214+
>
215+
> Assuming that your mysql data is available at `/opt/gitlab/mysql`
216+
>
217+
> ```bash
218+
> docker run --name=mysql -d \
219+
> -v /opt/gitlab/mysql:/var/lib/mysql \
220+
> sameersbn/mysql:latest
221+
> ```
222+
> This will start a mysql container with your existing mysql data.
223+
> All you need to do now is link this mysql container to the gitlab container using the `--link mysql:mysql` option.
224+
>
225+
> Refer to [Linking to MySQL Container](#linking-to-mysql-container) for more information.
226+
>
213227
214228
This docker image is configured to use a MySQL database backend. The database connection can be configured using environment variables. If not specified, the image will start a mysql server internally and use it. However in this case, the data stored in the mysql database will be lost if the container is stopped/deleted. To avoid this you should mount a volume at `/var/lib/mysql`.
215229
@@ -441,18 +455,20 @@ docker run --name=gitlab -d --link postgresql:postgresql \
441455
442456
## Redis
443457
444-
### Internal Redis Server
445-
446-
> **Warning**
447-
>
448-
> The internal redis server will soon be removed from the image.
458+
GitLab uses the redis server for its key-value data store. The redis server connection details can be specified using environment variables.
449459
450-
> Please use a linked [redis](#linking-to-redis-container) container
451-
> or a external [redis](#external-redis-server) server
460+
### Internal Redis Server
452461
453-
> You've been warned.
462+
The internal redis server has been removed from the image. Please use a [linked redis](#linking-to-redis-container) container or specify a [external redis](#external-redis-server) connection.
454463
455-
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.
464+
> **Notice**
465+
>
466+
> The internal mysql server will also be removed in the next release.
467+
>
468+
> If you have been using the internal mysql server, then please migrate to a using a [linked mysql server](#linking-to-mysql-container) using the migration instructions listed [here](#internal-mysql-server).
469+
>
470+
> **You've been warned**
471+
>
456472
457473
### External Redis Server
458474

assets/init

+36-7
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ if [ -n "${REDISIO_PORT_6379_TCP_ADDR}" ]; then
108108
REDIS_PORT=${REDIS_PORT:-${REDISIO_PORT_6379_TCP_PORT}}
109109
fi
110110

111-
# fallback to using internal redis server
112-
REDIS_HOST=${REDIS_HOST:-localhost}
111+
# fallback to default redis port
113112
REDIS_PORT=${REDIS_PORT:-6379}
114113

115114
# is a mysql or postgresql database linked?
@@ -136,6 +135,41 @@ case "${DB_TYPE}" in
136135
*) echo "Unsupported database adapter. Available adapters are mysql and postgres." && exit 1 ;;
137136
esac
138137

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+
165+
if [ -z "${REDIS_HOST}" ]; then
166+
echo "ERROR: "
167+
echo " Please configure the redis connection."
168+
echo " Refer http://git.io/PMnRSw for more information."
169+
echo " Cannot continue without a redis connection. Aborting..."
170+
exit 1
171+
fi
172+
139173
case "${GITLAB_HTTPS}" in
140174
true)
141175
GITLAB_PORT=${GITLAB_PORT:-443}
@@ -262,11 +296,6 @@ if [ "${DB_HOST}" == "localhost" ]; then
262296
fi
263297
fi
264298

265-
if [ "${REDIS_HOST}" == "localhost" ]; then
266-
echo "Starting redis server..."
267-
supervisorctl start redis-server >/dev/null
268-
fi
269-
270299
# configure git for the 'git' user
271300
sudo -u git -H git config --global user.name "GitLab"
272301
sudo -u git -H git config --global user.email "${GITLAB_EMAIL}"

assets/setup/install

-14
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,6 @@ stdout_logfile=/var/log/supervisor/%(program_name)s.log
165165
stderr_logfile=/var/log/supervisor/%(program_name)s.log
166166
EOF
167167

168-
# configure supervisord to start redis (manual)
169-
sed 's/daemonize yes/daemonize no/' -i /etc/redis/redis.conf
170-
cat > /etc/supervisor/conf.d/redis-server.conf <<EOF
171-
[program:redis-server]
172-
priority=20
173-
directory=/tmp
174-
command=/usr/bin/redis-server /etc/redis/redis.conf
175-
user=redis
176-
autostart=false
177-
autorestart=true
178-
stdout_logfile=/var/log/supervisor/%(program_name)s.log
179-
stderr_logfile=/var/log/supervisor/%(program_name)s.log
180-
EOF
181-
182168
# configure supervisord to start crond
183169
cat > /etc/supervisor/conf.d/cron.conf <<EOF
184170
[program:cron]

0 commit comments

Comments
 (0)