Skip to content

Commit

Permalink
Add Docker Swarm config file, and Swar&compose config file support
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Dowideit <[email protected]>
  • Loading branch information
Sven Dowideit authored and Dowideit, Sven (O&A, St. Lucia) committed Apr 18, 2018
1 parent 7e35505 commit d244882
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ These options should contain something like:

### Available Configuration Parameters

*Please refer the docker run command options for the `--env-file` flag where you can specify all required environment variables in a single file. This will save you from writing a potentially long docker run command. Alternatively you can use docker-compose.*
*Please refer the docker run command options for the `--env-file` flag where you can specify all required environment variables in a single file. This will save you from writing a potentially long docker run command. Alternatively you can use docker-compose. docker-compose users and Docker Swarm mode users can also use the [secrets and config file options](#docker-secrets-and-configs)*


Below is the complete list of available options that can be used to customize your gitlab installation.

Expand Down Expand Up @@ -1044,6 +1045,43 @@ Below is the complete list of available options that can be used to customize yo
| `RACK_ATTACK_BANTIME` | Number of seconds an IP should be banned after too many auth attempts. Defaults to `3600`. |
| `GITLAB_WORKHORSE_TIMEOUT` | Timeout for gitlab workhorse http proxy. Defaults to `5m0s`. |

### Docker secrets and configs

All the above environment variables can be put into a [secrets](https://docs.docker.com/compose/compose-file/#secrets) or [config](https://docs.docker.com/compose/compose-file/#configs) file
and then both docker-compose and Docker Swarm can import them into your gitlab container.

On startup, the gitlab container will source env vars from a config file named `gitlab-config`, and then a secrets file named `gitlab-secrets` (both mounted in the default locations).

To modify your existing `docker-compose.yml` file, add the following to your gitlab service:

> Note: you also need to change the docker-compose file version `version: "3.4"`.
```
services:
gitlab:
...
configs:
- gitlab-configs
secrets:
- gitlab-secrets
```

And then define those secrets and configs:

```
configs:
gitlab-configs:
file: ./gitlab.configs
secrets:
gitlab-secrets:
file: ./gitlab.secrets
```

If you're not using one of these files, then don't include its entry in the docker-compose file.

# Maintenance

## Creating backups
Expand Down
8 changes: 8 additions & 0 deletions assets/runtime/functions
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash
set -e

for file in /gitlab-configs /run/secrets/gitlab-secrets; do
if [[ -e "$file" ]]; then
echo "Loading $file"
source "$file"
fi
done
echo "Loading ${GITLAB_RUNTIME_DIR}/env-defaults"
source ${GITLAB_RUNTIME_DIR}/env-defaults

SYSCONF_TEMPLATES_DIR="${GITLAB_RUNTIME_DIR}/config"
Expand Down
14 changes: 13 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2'
version: '3.4'

services:
redis:
Expand Down Expand Up @@ -31,6 +31,10 @@ services:
- "10022:22"
volumes:
- /srv/docker/gitlab/gitlab:/home/git/data:Z
#configs:
# - gitlab-configs
#secrets:
# - gitlab-secrets
environment:
- DEBUG=false

Expand Down Expand Up @@ -148,3 +152,11 @@ services:
- OAUTH_AZURE_API_KEY=
- OAUTH_AZURE_API_SECRET=
- OAUTH_AZURE_TENANT_ID=

#configs:
# gitlab-configs:
# file: ./gitlab.configs
#
#secrets:
# gitlab-secrets:
# file: ./gitlab.secrets

0 comments on commit d244882

Please sign in to comment.