Skip to content

Commit 8b638b3

Browse files
authored
Merge pull request #1540 from SvenDowideit/docker-config-and-secrets-file-env
Add Docker Swarm config file, and Swarm & compose config file support
2 parents c0efa51 + 474fe9f commit 8b638b3

File tree

6 files changed

+199
-2
lines changed

6 files changed

+199
-2
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
*.gem
22
*.tar.gz
33

4-
docker-compose.yml

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,8 @@ These options should contain something like:
803803

804804
### Available Configuration Parameters
805805

806-
*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.*
806+
*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)*
807+
807808

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

@@ -1078,6 +1079,17 @@ Below is the complete list of available options that can be used to customize yo
10781079
| `RACK_ATTACK_BANTIME` | Number of seconds an IP should be banned after too many auth attempts. Defaults to `3600`. |
10791080
| `GITLAB_WORKHORSE_TIMEOUT` | Timeout for gitlab workhorse http proxy. Defaults to `5m0s`. |
10801081

1082+
### Docker secrets and configs
1083+
1084+
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
1085+
and then both docker-compose and Docker Swarm can import them into your gitlab container.
1086+
1087+
On startup, the gitlab container will source env vars from a config file labeled `gitlab-config`, and then a secrets file labeled `gitlab-secrets` (both mounted in the default locations).
1088+
1089+
See the exmample `config/docker-swarm/docker-compose.yml` file, and the example `gitlab.config` and `gitlab.secrets` file.
1090+
1091+
If you're not using one of these files, then don't include its entry in the docker-compose file.
1092+
10811093
# Maintenance
10821094

10831095
## Creating backups

assets/runtime/functions

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash
22
set -e
3+
4+
for file in /gitlab-configs /run/secrets/gitlab-secrets; do
5+
if [[ -e "$file" ]]; then
6+
echo "Loading $file"
7+
source "$file"
8+
fi
9+
done
10+
echo "Loading ${GITLAB_RUNTIME_DIR}/env-defaults"
311
source ${GITLAB_RUNTIME_DIR}/env-defaults
412

513
SYSCONF_TEMPLATES_DIR="${GITLAB_RUNTIME_DIR}/config"
+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
version: '3.4'
2+
3+
services:
4+
redis:
5+
restart: always
6+
image: sameersbn/redis:latest
7+
command:
8+
- --loglevel warning
9+
volumes:
10+
- /srv/docker/gitlab/redis:/var/lib/redis:Z
11+
12+
postgresql:
13+
restart: always
14+
image: sameersbn/postgresql:9.6-2
15+
volumes:
16+
- /srv/docker/gitlab/postgresql:/var/lib/postgresql:Z
17+
environment:
18+
- DB_USER=gitlab
19+
- DB_PASS=password
20+
- DB_NAME=gitlabhq_production
21+
- DB_EXTENSION=pg_trgm
22+
23+
gitlab:
24+
restart: always
25+
image: sameersbn/gitlab:10.7.2
26+
depends_on:
27+
- redis
28+
- postgresql
29+
ports:
30+
- "10080:80"
31+
- "10022:22"
32+
volumes:
33+
- /srv/docker/gitlab/gitlab:/home/git/data:Z
34+
configs:
35+
- gitlab-configs
36+
secrets:
37+
- gitlab-secrets
38+
environment:
39+
- DEBUG=false
40+
41+
- DB_ADAPTER=postgresql
42+
- DB_HOST=postgresql
43+
- DB_PORT=5432
44+
- DB_USER=gitlab
45+
- DB_PASS=password
46+
- DB_NAME=gitlabhq_production
47+
48+
- REDIS_HOST=redis
49+
- REDIS_PORT=6379
50+
51+
- TZ=Asia/Kolkata
52+
- GITLAB_TIMEZONE=Kolkata
53+
54+
- GITLAB_HTTPS=false
55+
- SSL_SELF_SIGNED=false
56+
57+
- GITLAB_HOST=localhost
58+
- GITLAB_PORT=10080
59+
- GITLAB_SSH_PORT=10022
60+
- GITLAB_RELATIVE_URL_ROOT=
61+
- GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alphanumeric-string
62+
- GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alphanumeric-string
63+
- GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alphanumeric-string
64+
65+
- GITLAB_ROOT_PASSWORD=
66+
- GITLAB_ROOT_EMAIL=
67+
68+
- GITLAB_NOTIFY_ON_BROKEN_BUILDS=true
69+
- GITLAB_NOTIFY_PUSHER=false
70+
71+
- GITLAB_EMAIL=notifications@example.com
72+
- GITLAB_EMAIL_REPLY_TO=noreply@example.com
73+
- GITLAB_INCOMING_EMAIL_ADDRESS=reply@example.com
74+
75+
- GITLAB_BACKUP_SCHEDULE=daily
76+
- GITLAB_BACKUP_TIME=01:00
77+
78+
- SMTP_ENABLED=false
79+
- SMTP_DOMAIN=www.example.com
80+
- SMTP_HOST=smtp.gmail.com
81+
- SMTP_PORT=587
82+
- SMTP_USER=mailer@example.com
83+
- SMTP_PASS=password
84+
- SMTP_STARTTLS=true
85+
- SMTP_AUTHENTICATION=login
86+
87+
- IMAP_ENABLED=false
88+
- IMAP_HOST=imap.gmail.com
89+
- IMAP_PORT=993
90+
- IMAP_USER=mailer@example.com
91+
- IMAP_PASS=password
92+
- IMAP_SSL=true
93+
- IMAP_STARTTLS=false
94+
95+
- OAUTH_ENABLED=false
96+
- OAUTH_AUTO_SIGN_IN_WITH_PROVIDER=
97+
- OAUTH_ALLOW_SSO=
98+
- OAUTH_BLOCK_AUTO_CREATED_USERS=true
99+
- OAUTH_AUTO_LINK_LDAP_USER=false
100+
- OAUTH_AUTO_LINK_SAML_USER=false
101+
- OAUTH_EXTERNAL_PROVIDERS=
102+
103+
- OAUTH_CAS3_LABEL=cas3
104+
- OAUTH_CAS3_SERVER=
105+
- OAUTH_CAS3_DISABLE_SSL_VERIFICATION=false
106+
- OAUTH_CAS3_LOGIN_URL=/cas/login
107+
- OAUTH_CAS3_VALIDATE_URL=/cas/p3/serviceValidate
108+
- OAUTH_CAS3_LOGOUT_URL=/cas/logout
109+
110+
- OAUTH_GOOGLE_API_KEY=
111+
- OAUTH_GOOGLE_APP_SECRET=
112+
- OAUTH_GOOGLE_RESTRICT_DOMAIN=
113+
114+
- OAUTH_FACEBOOK_API_KEY=
115+
- OAUTH_FACEBOOK_APP_SECRET=
116+
117+
- OAUTH_TWITTER_API_KEY=
118+
- OAUTH_TWITTER_APP_SECRET=
119+
120+
- OAUTH_GITHUB_API_KEY=
121+
- OAUTH_GITHUB_APP_SECRET=
122+
- OAUTH_GITHUB_URL=
123+
- OAUTH_GITHUB_VERIFY_SSL=
124+
125+
- OAUTH_GITLAB_API_KEY=
126+
- OAUTH_GITLAB_APP_SECRET=
127+
128+
- OAUTH_BITBUCKET_API_KEY=
129+
- OAUTH_BITBUCKET_APP_SECRET=
130+
131+
- OAUTH_SAML_ASSERTION_CONSUMER_SERVICE_URL=
132+
- OAUTH_SAML_IDP_CERT_FINGERPRINT=
133+
- OAUTH_SAML_IDP_SSO_TARGET_URL=
134+
- OAUTH_SAML_ISSUER=
135+
- OAUTH_SAML_LABEL="Our SAML Provider"
136+
- OAUTH_SAML_NAME_IDENTIFIER_FORMAT=urn:oasis:names:tc:SAML:2.0:nameid-format:transient
137+
- OAUTH_SAML_GROUPS_ATTRIBUTE=
138+
- OAUTH_SAML_EXTERNAL_GROUPS=
139+
- OAUTH_SAML_ATTRIBUTE_STATEMENTS_EMAIL=
140+
- OAUTH_SAML_ATTRIBUTE_STATEMENTS_NAME=
141+
- OAUTH_SAML_ATTRIBUTE_STATEMENTS_FIRST_NAME=
142+
- OAUTH_SAML_ATTRIBUTE_STATEMENTS_LAST_NAME=
143+
144+
- OAUTH_CROWD_SERVER_URL=
145+
- OAUTH_CROWD_APP_NAME=
146+
- OAUTH_CROWD_APP_PASSWORD=
147+
148+
- OAUTH_AUTH0_CLIENT_ID=
149+
- OAUTH_AUTH0_CLIENT_SECRET=
150+
- OAUTH_AUTH0_DOMAIN=
151+
152+
- OAUTH_AZURE_API_KEY=
153+
- OAUTH_AZURE_API_SECRET=
154+
- OAUTH_AZURE_TENANT_ID=
155+
156+
configs:
157+
gitlab-configs:
158+
file: ./gitlab.configs
159+
160+
secrets:
161+
gitlab-secrets:
162+
file: ./gitlab.secrets

contrib/docker-swarm/gitlab.config

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# config file to be sourced on startup - will over-ride any env set in the docker-compose.yml
2+
3+
TEST=none

contrib/docker-swarm/gitlab.secret

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# config file to be sourced on startup - will over-ride any env set in the docker-compose.yml
2+
3+
LDAP_ENABLED=true
4+
LDAP_LABEL="LDAP login"
5+
LDAP_HOST=pool.ldap.example.com
6+
LDAP_PORT=3268
7+
LDAP_BIND_DN=the-ldap
8+
LDAP_PASS=no-not-really
9+
LDAP_BASE=ou=People,dc=example,dc=com
10+
#LDAP_LOWERCASE_USERNAMES=true
11+
##LDAP_USER_FILTER=uid={login}
12+
##LDAP_UID=
13+
#

0 commit comments

Comments
 (0)