Skip to content

Commit

Permalink
Add redis auth support sameersbn#1026 auto commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gnuhub committed Jun 21, 2020
1 parent 36e6bac commit 1b9089e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,12 @@ The internal redis server has been removed from the image. Please use a [linked

The image can be configured to use an external redis server. The configuration should be specified using environment variables while starting the GitLab image.

*Assuming that the redis server host is 192.168.1.100*
*Assuming that the redis server host is 192.168.1.100*, and configured to use authentication*

```bash
docker run --name gitlab -it --rm \
--env 'REDIS_HOST=192.168.1.100' --env 'REDIS_PORT=6379' \
--env 'REDIS_PASSWORD=p4ssw0rd' \
sameersbn/gitlab:13.0.6
```

Expand Down
2 changes: 1 addition & 1 deletion assets/runtime/config/gitlabhq/resque.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test:
url: redis://localhost:6379
production:
# Redis (single instance)
url: redis://{{REDIS_HOST}}:{{REDIS_PORT}}/{{REDIS_DB_NUMBER}}
url: redis://{{REDIS_PASSWORD}}{{REDIS_HOST}}:{{REDIS_PORT}}/{{REDIS_DB_NUMBER}}
##
# Redis + Sentinel (for HA)
#
Expand Down
13 changes: 11 additions & 2 deletions assets/runtime/functions
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,12 @@ gitlab_finalize_redis_parameters() {
}

gitlab_check_redis_connection() {
REDIS_FLAG=""
if [[ -n ${REDIS_PASSWORD} ]]; then
REDIS_FLAG="-a ${REDIS_PASSWORD}"
fi
timeout=60
while ! redis-cli -h ${REDIS_HOST} -p ${REDIS_PORT} -n ${REDIS_DB_NUMBER} ping >/dev/null 2>&1
while ! redis-cli -h ${REDIS_HOST} ${REDIS_FLAG} -p ${REDIS_PORT} -n ${REDIS_DB_NUMBER} ping >/dev/null 2>&1
do
timeout=$(expr $timeout - 1)
if [[ $timeout -eq 0 ]]; then
Expand All @@ -226,10 +230,15 @@ gitlab_configure_redis() {
gitlab_finalize_redis_parameters
gitlab_check_redis_connection

if [[ -n ${REDIS_PASSWORD} ]]; then
REDIS_PASSWORD=':'${REDIS_PASSWORD}'@'
fi

update_template ${GITLAB_RESQUE_CONFIG} \
REDIS_HOST \
REDIS_PORT \
REDIS_DB_NUMBER
REDIS_DB_NUMBER \
REDIS_PASSWORD
}

gitlab_configure_gitaly() {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
image: redis:5.0.9
command:
- --loglevel warning
- --requirepass "p4ssw0rd"
volumes:
- redis-data:/var/lib/redis:Z

Expand Down

0 comments on commit 1b9089e

Please sign in to comment.