Commit 92a6ee95bad6cb07b22d9a22977b5d1224d518bf

Authored by Gustavo Duarte
0 parents
Exists in master

Initial release

Showing 2 changed files with 149 additions and 0 deletions   Show diff stats
Vagrantfile 0 → 100644
  1 +++ a/Vagrantfile
... ... @@ -0,0 +1,18 @@
  1 +
  2 +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
  3 +VAGRANTFILE_API_VERSION = "2"
  4 +
  5 +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  6 +
  7 + config.vm.box = "centos/7"
  8 +
  9 + config.vm.box_url = "centos/7"
  10 +
  11 + config.vm.network "private_network", ip: "10.0.3.17"
  12 +
  13 + config.vm.provision "shell", keep_color: true, path: 'provision.sh'
  14 +
  15 + #config.vm.network :forwarded_port, guest: 8080, host: 8080 # Gitlab
  16 + config.vm.network :forwarded_port, guest: 8081, host: 8081 # Nginx
  17 +
  18 +end
... ...
provision.sh 0 → 100755
  1 +++ a/provision.sh
... ... @@ -0,0 +1,131 @@
  1 +#!/bin/bash
  2 +
  3 +set -x
  4 +
  5 +# Disable SELINUX (for now)
  6 +sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
  7 +setenforce 0
  8 +
  9 +yum -y install epel-release
  10 +yum -y install wget postgresql-server nginx
  11 +
  12 +wget -P /etc/yum.repos.d/ https://copr.fedorainfracloud.org/coprs/softwarepublico/v4/repo/epel-7/softwarepublico-v4-epel-7.repo
  13 +
  14 +yum -y install gitlab
  15 +
  16 +############################################
  17 +# Coisas estranhas:
  18 +#
  19 +# Installing : gitlab-shell-2.4.0-5.1.noarch
  20 +# id: git: no such user
  21 +# mkdir -p /var/lib/gitlab-shell/repositories/: OK
  22 +# mkdir -p /var/lib/gitlab-shell/.ssh: OK
  23 +# chmod 700 /var/lib/gitlab-shell/.ssh: OK
  24 +# touch /var/lib/gitlab-shell/.ssh/authorized_keys: OK
  25 +# chmod 600 /var/lib/gitlab-shell/.ssh/authorized_keys: OK
  26 +# chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/: OK
  27 +# find /var/lib/gitlab-shell/repositories/ -type d -exec chmod g+s {} ;: OK
  28 +#
  29 +# <snip>
  30 +#
  31 +# Installing : gitlab-7.6.2-13.2.noarch
  32 +# chown: cannot access ‘/var/lib/gitlab-assets’: No such file or directory
  33 +# Redirecting to /bin/systemctl start redis.service
  34 +# rake aborted!
  35 +# Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret
  36 +#
  37 +# Tasks: TOP => db:migrate:status => environment
  38 +# (See full trace by running task with --trace)
  39 +# rake aborted!
  40 +# Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret
  41 +#
  42 +# Tasks: TOP => gitlab:setup => environment
  43 +# (See full trace by running task with --trace)
  44 +# I, [2016-04-25T22:50:47.389656 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_32-7d94ec26bfa902d9573dac174421752a.png
  45 +# I, [2016-04-25T22:50:47.391563 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_64-cfef80f36a1826b9c90eeb38534dbd18.png
  46 +#
  47 +# <snip>
  48 +#
  49 +############################################
  50 +
  51 +
  52 +postgresql-setup initdb
  53 +
  54 +#TODO: edit /var/lib/pgsql/data/pg_hba.conf ?
  55 +
  56 +systemctl enable postgresql redis
  57 +systemctl start postgresql redis
  58 +sudo -u postgres createuser git
  59 +#sudo -u postgres createdb --owner=git gitlabhq_production
  60 +cd /usr/lib/gitlab
  61 +sudo -u git bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done
  62 +
  63 +sed -i 's,http://localhost:8080/,http://localhost:8080/gitlab,' /etc/gitlab-shell/config.yml
  64 +
  65 +echo 'production: redis://localhost:6379' > /usr/lib/gitlab/config/resque.yml
  66 +sed -i 's,localhost,localhost\n relative_url_root: /gitlab,' /etc/gitlab/gitlab.yml
  67 +
  68 +cat << EOF > /usr/lib/gitlab/config/initializers/gitlab_shell_secret_token.rb
  69 +Gitlab::Application.configure do
  70 + config.relative_url_root = "/gitlab"
  71 +end
  72 +EOF
  73 +
  74 +cat << EOF > /etc/nginx/conf.d/gitlab.conf
  75 +upstream gitlab {
  76 + server 0.0.0.0:8080 fail_timeout=10s;
  77 +}
  78 +
  79 +server {
  80 + listen *:8081;
  81 + server_name localhost:8081;
  82 + underscores_in_headers on;
  83 + access_log /var/log/nginx/gitlab.access.log;
  84 + error_log /var/log/nginx/gitlab.error.log;
  85 + client_max_body_size 20m;
  86 +
  87 + location /gitlab/assets/ {
  88 + alias /usr/lib/gitlab/public/assets/;
  89 + }
  90 +
  91 + location /gitlab/uploads/ {
  92 + alias /usr/lib/gitlab/public/uploads/;
  93 + }
  94 +
  95 + location / {
  96 + proxy_pass http://gitlab;
  97 + proxy_read_timeout 90;
  98 + proxy_connect_timeout 90;
  99 + proxy_redirect off;
  100 + proxy_set_header Host localhost:8081;
  101 + proxy_set_header X-Real-IP \$remote_addr;
  102 + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
  103 + }
  104 +}
  105 +EOF
  106 +
  107 +systemctl enable nginx
  108 +systemctl restart nginx
  109 +
  110 +
  111 +sed -i 's/# ENV/ENV/' /etc/gitlab/unicorn.rb
  112 +
  113 +sed -i 's/# config.relative_url_root/config.relative_url_root/' /usr/lib/gitlab/config/application.rb
  114 +
  115 +chown -R git:git /usr/lib/gitlab/tmp/cache
  116 +chown -R git:git /usr/lib/gitlab/public/assets
  117 +chown -R git:git /var/lib/gitlab-assets
  118 +
  119 +cd /usr/lib/gitlab &&
  120 +sudo -u git bundle exec rake assets:precompile RAILS_ENV=production
  121 +
  122 +systemctl enable gitlab
  123 +systemctl start gitlab
  124 +
  125 +
  126 +
  127 +# bootstrap / provision
  128 +
  129 +#sudo su - vagrant
  130 +
  131 +
... ...