Make GitLab and GitLab Shell configurable via Environment Variables by default
Created by: amtrack
Most apps today use environment variables for configuration. Background: http://12factor.net/config
Making GitLab and GitLab Shell configurable via environment variables would be a benefit for several use cases:
- Developing GitLab and GitLab Shell (see bkeepers/dotenv)
- Building debian packages (see crohr/pkgr)
- Building docker images (see sameersbn/docker-gitlab)
- PaaS Deployment (see amtrack/buildpack-gitlab)
@crohr, @sameersbn:
Currently we're all using sed
or patch
for patching the config files, right? :-)
- https://github.com/gitlabhq/gitlabhq/blob/master/bin/pkgr_before_precompile.sh#L10-L14
- https://github.com/sameersbn/docker-gitlab/blob/master/assets/init#L340-L342
- https://github.com/amtrack/buildpack-gitlab/blob/master/bin/compile#L66-L67
Let's unite our forces here on GitLab upstream to benefit all!
For backwards compatibility i suggest still supporting config files, but values from environment variables should override values from config files.
For the first, i think the following environment variable would be a good start:
-
DATABASE_URL
(already implemented in rails > 4.1.0) -
REDIS_URL
(right now only ifconfig/resque.yml
doesn't exist?) -
GITLAB_URL
(should be shared with GitLab Shell) -
GIT_USER
(should be shared with GitLab Shell) -
REPOS_PATH
(should be shared with GitLab Shell) SMTP_URL
- What else?
A simple solution would be to read all config files through ERB, but
- you would still have to copy the example config files to the right location.
- it might be confusing for people who don't use environment variables
A better solution imho would be to implement it in the code directly (maybe here: https://github.com/gitlabhq/gitlabhq/blob/master/config/initializers/1_settings.rb and https://github.com/gitlabhq/gitlab-shell/blob/master/lib/gitlab_config.rb) This would make the overriding of the configuration more streamlined.
Which approach would you prefer? What else has to be done?