PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/install/installation.md

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