PageRenderTime 53ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/install/README.md

https://gitlab.com/fostertheweb/gitlab-ci
Markdown | 276 lines | 170 code | 106 blank | 0 comment | 0 complexity | f6b7336fb2ca52f408978889be4298e9 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # Select Version to Install
  2. Make sure you view this installation guide from the branch (version) of GitLab CI you would like to install. In most cases
  3. this should be the highest numbered stable branch (example shown below).
  4. ![capture](http://i.imgur.com/fmdlXxa.png)
  5. If this is unclear check the [GitLab Blog](http://blog.gitlab.org/) for installation guide links by version.
  6. ## GitLab CI 7.12 requires GitLab 7.12 or newer
  7. other [requirements](requirements.md)
  8. # Setup:
  9. ## 1. Packages / Dependencies
  10. `sudo` is not installed on Debian by default. Make sure your system is
  11. up-to-date and install it.
  12. sudo apt-get update
  13. sudo apt-get upgrade
  14. **Note:**
  15. During this installation some files will need to be edited manually. If
  16. you are familiar with vim set it as default editor with the commands
  17. below. If you are not familiar with vim please skip this and keep using
  18. the default editor.
  19. # Install vim
  20. sudo apt-get install vim
  21. sudo update-alternatives --set editor /usr/bin/vim.basic
  22. Install the required packages:
  23. sudo apt-get install wget curl gcc checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev openssh-server git-core libyaml-dev postfix libpq-dev libicu-dev openssl nodejs
  24. sudo apt-get install redis-server
  25. # 2. Ruby
  26. Download Ruby and compile it:
  27. mkdir /tmp/ruby && cd /tmp/ruby
  28. curl --progress http://cache.ruby-lang.org/pub/ruby/ruby-2.1.6.tar.bz2 | tar xj
  29. cd ruby-2.1.6/
  30. ./configure --disable-install-rdoc
  31. make
  32. sudo make install
  33. Install the Bundler Gem:
  34. sudo gem install bundler --no-ri --no-rdoc
  35. ## 3. GitLab CI user:
  36. sudo adduser --disabled-login --gecos 'GitLab CI' gitlab_ci
  37. ## 4. Prepare the database
  38. We recommend PostgreSQL but you can also use MySQL
  39. ### MySQL
  40. # Install the database packages
  41. sudo apt-get install mysql-server mysql-client libmysqlclient-dev
  42. # Login to MySQL
  43. $ mysql -u root -p
  44. # Create the GitLab CI database
  45. mysql> CREATE DATABASE IF NOT EXISTS `gitlab_ci_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  46. # Create the MySQL User change $password to a real password
  47. mysql> CREATE USER 'gitlab_ci'@'localhost' IDENTIFIED BY '$password';
  48. # Grant proper permissions to the MySQL User
  49. mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlab_ci_production`.* TO 'gitlab_ci'@'localhost';
  50. # Logout MYSQL
  51. mysql> exit;
  52. ### PostgreSQL
  53. # Install the database packages
  54. sudo apt-get install -y postgresql-9.1 libpq-dev
  55. # Login to PostgreSQL
  56. sudo -u postgres psql -d template1
  57. # Create a user for GitLab CI. We do not specify a password because we are using peer authentication.
  58. template1=# CREATE USER gitlab_ci;
  59. # Create the GitLab CI production database & grant all privileges on database
  60. template1=# CREATE DATABASE gitlab_ci_production OWNER gitlab_ci;
  61. # Quit the database session
  62. template1=# \q
  63. # Try connecting to the new database with the new user
  64. sudo -u gitlab_ci -H psql -d gitlab_ci_production
  65. ## 5. Get code
  66. cd /home/gitlab_ci/
  67. sudo -u gitlab_ci -H git clone https://gitlab.com/gitlab-org/gitlab-ci.git
  68. cd gitlab-ci
  69. sudo -u gitlab_ci -H git checkout 7-12-stable
  70. ## 6. Setup application
  71. # Edit application settings
  72. # Production
  73. sudo -u gitlab_ci -H cp config/application.yml.example config/application.yml
  74. sudo -u gitlab_ci -H editor config/application.yml
  75. # Development
  76. #sudo -u gitlab_ci -H cp config/application.yml.example.development config/application.yml
  77. # Copy the example secrets file
  78. sudo -u gitlab_ci -H cp config/secrets.yml.example config/secrets.yml
  79. sudo -u gitlab_ci -H chmod 0600 config/secrets.yml
  80. # Edit web server settings
  81. sudo -u gitlab_ci -H cp config/unicorn.rb.example config/unicorn.rb
  82. sudo -u gitlab_ci -H editor config/unicorn.rb
  83. # Create socket and pid directories
  84. sudo -u gitlab_ci -H mkdir -p tmp/sockets/
  85. sudo chmod -R u+rwX tmp/sockets/
  86. sudo -u gitlab_ci -H mkdir -p tmp/pids/
  87. sudo chmod -R u+rwX tmp/pids/
  88. # Change the permissions of the directory where build traces are stored
  89. sudo chmod -R u+rwX builds/
  90. ### Install gems
  91. # For MySQL (note, the option says "without ... postgres")
  92. sudo -u gitlab_ci -H bundle install --without development test postgres --deployment
  93. # Or for PostgreSQL (note, the option says "without ... mysql")
  94. sudo -u gitlab_ci -H bundle install --without development test mysql --deployment
  95. ### Setup db
  96. # mysql
  97. sudo -u gitlab_ci -H cp config/database.yml.mysql config/database.yml
  98. # postgres
  99. sudo -u gitlab_ci -H cp config/database.yml.postgresql config/database.yml
  100. # Edit user/password (not necessary with default Postgres setup)
  101. sudo -u gitlab_ci -H editor config/database.yml
  102. # Setup tables
  103. sudo -u gitlab_ci -H bundle exec rake setup RAILS_ENV=production
  104. # Setup schedules
  105. sudo -u gitlab_ci -H bundle exec whenever -w RAILS_ENV=production
  106. ### Secure secrets.yml
  107. The `secrets.yml` file stores encryption keys for sessions and secure variables.
  108. Backup `secrets.yml` someplace safe, but don't store it in the same place as your database backups.
  109. Otherwise your secrets are exposed if one of your backups is compromised.
  110. ## 8. Install Init Script
  111. Copy the init script (will be /etc/init.d/gitlab_ci):
  112. sudo cp /home/gitlab_ci/gitlab-ci/lib/support/init.d/gitlab_ci /etc/init.d/gitlab_ci
  113. Make GitLab CI start on boot:
  114. sudo update-rc.d gitlab_ci defaults 21
  115. Start your GitLab CI instance:
  116. sudo service gitlab_ci start
  117. # or
  118. sudo /etc/init.d/gitlab_ci start
  119. # 8. Nginx
  120. ## Installation
  121. sudo apt-get install nginx
  122. ## Site Configuration
  123. Download an example site config:
  124. sudo cp /home/gitlab_ci/gitlab-ci/lib/support/nginx/gitlab_ci /etc/nginx/sites-available/gitlab_ci
  125. sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci
  126. Make sure to edit the config file to match your setup:
  127. # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
  128. # to the IP address and fully-qualified domain name
  129. # of your host serving GitLab CI
  130. sudo editor /etc/nginx/sites-enabled/gitlab_ci
  131. ## Check your configuration
  132. sudo nginx -t
  133. ## Start nginx
  134. sudo /etc/init.d/nginx start
  135. # 9. GitLab OAuth2 application
  136. Go to the admin area of GitLab, to the `Application` section. Create an application for the GitLab CI
  137. For callback URL use: `http://ci.example.com/user_sessions/callback` if you use http, or `https://ci.example.com/user_sessions/callback` if you use https.
  138. When `app_id` and `app_secret` are generated add them to the GitLab CI config:
  139. ```
  140. production:
  141. gitlab_server:
  142. url: 'http://gitlab.example.com'
  143. app_id: XXXXXX
  144. app_secret: XXXXXX
  145. ```
  146. # 10. Runners
  147. Now you need Runners to process your builds.
  148. Checkout the [Gitlab Runner section](https://about.gitlab.com/gitlab-ci/#gitlab-runner) to install it
  149. # Done!
  150. Visit YOUR_SERVER for your first GitLab CI login.
  151. You will be asked to authorize with your GitLab credentials.
  152. **Enjoy!**
  153. ## Advanced settings
  154. ### SMTP email settings
  155. If you want to use SMTP do next:
  156. # Copy config file
  157. sudo -u gitlab_ci -H cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb
  158. # Edit it with your settings
  159. sudo -u gitlab_ci -H editor config/initializers/smtp_settings.rb
  160. Restart application
  161. ### Custom Redis Connection
  162. If you'd like Resque to connect to a Redis server on a non-standard port or on
  163. a different host, you can configure its connection string via the
  164. `config/resque.yml` file.
  165. # example
  166. production: redis://redis.example.tld:6379
  167. If you want to connect the Redis server via socket, then use the "unix:" URL scheme
  168. and the path to the Redis socket file in the `config/resque.yml` file.
  169. # example
  170. production: unix:/path/to/redis/socket