gitlab-sei.tex 14.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
\section{Gitlab}\label{gitlab}

\subsection{Instalar Postgresql}


\fbox{\parbox{\textwidth}{
\texttt{sudo yum localinstall http://yum.postgresql.org/9.3/\\redhat/rhel-6-x86\_64/pgdg-centos93-9.3-1.noarch.rpm -y}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum install postgresql93 postgresql93-devel postgresql93-libs postgresql93-server -y
}}}

\subsubsection{Inicializar database}


\fbox{\parbox{\textwidth}{
\texttt{
sudo service postgresql-9.3 initdb
}}}

\subsubsection{Iniciar postgresql com o sistema}

\fbox{\parbox{\textwidth}{
\texttt{
sudo chkconfig postgresql-9.3 on
}}}

\subsubsection{Iniciar postgresql}

\fbox{\parbox{\textwidth}{
\texttt{
sudo service postgresql-9.3 start
}}}

\subsection{Adicionar repositório EPEL}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum  -y install wget vim
}}}
\fbox{\parbox{\textwidth}{
\texttt{
sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 \\https://www.fedoraproject.org/static/0608B895.txt
}}}
\fbox{\parbox{\textwidth}{
\texttt{
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
}}}

\subsection{Adicionar repositório PUIAS Computational (necessário o download de algumas dependências)}

\fbox{\parbox{\textwidth}{
\texttt{
sudo rpm -Uvh \\https://dl.fedoraproject.org/pub/epel/6/x86\_64/epel-release-6-8.noarch.rpm
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo wget -O /etc/yum.repos.d/PUIAS\_6\_computational.repo \\https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/\\PUIAS\_6\_computational.repo
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias \\http://springdale.math.ias.edu/data/puias/6/x86\_64/os/RPM-GPG-KEY-puias
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
}}}

\subsubsection{Ativar repositório PUIAS}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum -y install yum-utils
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum-config-manager --enable epel --enable PUIAS\_6\_computational
}}}

\subsection{Atualizar todos os pacotes e intalar alguns pacotes adincionais}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum -y update
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum -y groupinstall 'Development Tools'
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes
}}}

\subsection{Adicionar redis para iniciar com o sistema e iniciar o sistema}

\fbox{\parbox{\textwidth}{
\texttt{
sudo chkconfig redis on
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo service redis start
}}}

\subsection{Instalar o servidor de email postfix}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum -y install postfix
}}}

\subsection{Remover qualquer pacote git que tenha instalado}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum -y remove git
}}}

\subsection{Instalar git 1.9.0 e suas dependências}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum -y install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo mkdir /tmp/git \&\& cd /tmp/git}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo wget https://git-core.googlecode.com/files/git-1.9.0.tar.gz}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo tar xzf git-1.9.0.tar.gz}}}

\fbox{\parbox{\textwidth}{
\texttt{
cd git-1.9.0/}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo ./configure}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo make}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo make prefix=/usr/local install}}}

\subsection{Remover qualquer ruby instalado, e download do ruby-2.0.0-p451}

\fbox{\parbox{\textwidth}{
\texttt{
sudo yum remove ruby -y}}}

\fbox{\parbox{\textwidth}{
\texttt{
mkdir /tmp/ruby \&\& cd /tmp/ruby}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.gz | tar xz
}}}

\emph{NOTA:}

\fbox{\parbox{\textwidth}{
\texttt{
Se não for possível utilizar o host "ruby-2.0.0-p451", você pode tentar esse comando: \\sudo curl --progress http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.bz2 | tar xj
}}}

\subsection{Install ruby 2.0.0}

\fbox{\parbox{\textwidth}{
\texttt{
cd ruby-2.0.0-p451
\\./configure --disable-install-rdoc
\\make
\\sudo make prefix=/usr/local install
}}}

\subsection{Instalar a bundler gem}

\fbox{\parbox{\textwidth}{
\texttt{
sudo /usr/local/bin/gem install bundler --no-ri --no-rdoc
}}}

\subsection{Ciar um usuário git que tenha as permissões corretas no Gitlab}

\fbox{\parbox{\textwidth}{
\texttt{
sudo adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git
}}}

\subsection{Clonar o gitlab-shell no repositório}

\fbox{\parbox{\textwidth}{
\texttt{
sudo su
\\cd /home/git
\\sudo -u git -H /usr/local/bin/git clone https://gitlab.com/gitlab-org/gitlab-shell.git
\\cd gitlab-shell/
/usr/local/bin/git reset --hard v1.9.3
}}}

\subsection{Configurar o nome do host e instalar gitlab-shell}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H cp config.yml.example config.yml
\\sudo -u git -H vim config.yml
\\sudo -u git -H /usr/local/bin/ruby ./bin/install
restorecon -Rv /home/git/.ssh
}}}

\subsection{Criar database gitlabhq\_production, e se for desenvolver no gitlab criar gitlabhq\_development and gitlabhq\_test}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u postgres psql -d template1
CREATE USER git;
CREATE DATABASE gitlabhq\_production OWNER git;
CREATE DATABASE gitlabhq\_development OWNER git;
CREATE DATABASE gitlabhq\_test OWNER git;
}}}

\subsection{Adicionar o usuário git no pg\_hba.conf para conceder permissões}

\fbox{\parbox{\textwidth}{
\texttt{
vim /var/lib/pgsql/9.3/data/pg\_hba.conf
}}}

O fim do arquivo deve se parecer o código abaixo:

\fbox{\parbox{\textwidth}{
\texttt{
\# TYPE  DATABASE        USER            ADDRESS                 METHOD
\\\# "local" is for Unix domain socket connections only
\\local   all             postgres                                     peer
\\local   all             git                                     trust
\\\# IPv4 local connections:
\\host    all             postgres             127.0.0.1/32            ident
\\host    all             git             127.0.0.1/32            trust
\\\# IPv6 local connections:
\\host    all             postgres             ::1/128                 ident
\\host    all             git             ::1/128                 trust
}}}

\fbox{\parbox{\textwidth}{
\texttt{
[ESC]:wq!
}}}

\subsection{Reiniciar postgresql}

\fbox{\parbox{\textwidth}{
\texttt{
service postgresql-9.3 restart
}}}

\subsection{Clonar and configurar o repositório do gitlab}

\fbox{\parbox{\textwidth}{
\texttt{
cd /home/git
}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\sudo -u git -H /usr/local/bin/git clone \\https://github.com/colab-community/gitlabhq.git -b 7-0-stable gitlab}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\cd /home/git/gitlab}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\chown -R git {log,tmp}}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\chmod -R u+rwX {log,tmp}
}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\sudo -u git -H mkdir /home/git/gitlab-satellites}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\chmod -R u+rwX tmp/{pids,sockets}
}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\chmod -R u+rwX public/uploads}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb}}}

\fbox{\parbox{\textwidth}{
\texttt{
\\sudo -u git -H cp config/initializers/rack\_attack.rb.example config/initializers/rack\_attack.rb
}}}

\subsection{Mudar a porta usada para o gitlab, nesse caso use a porta 8090}

\fbox{\parbox{\textwidth}{
\texttt{
sudo vim /home/git/gitlab/config/unicorn.rb
}}}

Mude:

\fbox{\parbox{\textwidth}{
\texttt{
listen "127.0.0.1:8080", :tcp\_nopush => true
}}}

Para:

\fbox{\parbox{\textwidth}{
\texttt{
listen "127.0.0.1:8090", :tcp\_nopush => true
}}}

\fbox{\parbox{\textwidth}{
\texttt{
[ESC]:wq!
}}}

\subsection{Mudar URL defautl no gitlab-shell/config.yml}

\fbox{\parbox{\textwidth}{
\texttt{
sudo vim /home/git/gitlab-shell/config.yml
}}}

Altere a sequinte linha:

\fbox{\parbox{\textwidth}{
\texttt{
gitlab\_url: "http://127.0.0.1:8090/gitlab"
}}}

Para, usando o seu IP:

\fbox{\parbox{\textwidth}{
\texttt{
gitlab\_url: "http://127.0.0.1:8090/"
}}}

\subsection{Configurar git e database}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/git config --global user.name "GitLab"
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/git config --global user.email "gitlab@localhost"}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/git config --global core.autocrlf input}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git cp config/database.yml.postgresql config/database.yml}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H chmod o-rwx config/database.yml
}}}

\subsection{Configurar o bundle}

\fbox{\parbox{\textwidth}{
\texttt{
cd /home/git/gitlab
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/bundle config build.pg --with-pg-config=/usr/\\pgsql-9.3/bin/pg\_config}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/bundle config build.nokogiri --use-system-libraries
}}}

\subsection{Edite arquivos sudores para deixar que bundle, git e gem executem no modo sudo.}

\emph{NOTA:}

\fbox{\parbox{\textwidth}{
\texttt{
The path "/usr/bin:/usr/pgsql-9.3/bin/" will be only in this file if you installed postgresql before, if you didn't just remove it from those lines.
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo vim /etc/sudoers
}}}

Altere a linha

\fbox{\parbox{\textwidth}{
\texttt{
Defaults    secure\_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-9.3/bin/
}}}

Para

\fbox{\parbox{\textwidth}{
\texttt{
Defaults    secure\_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-9.3/bin/:/usr/\\local/bin/
}}}

\fbox{\parbox{\textwidth}{
\texttt{
[ESC]:wq!
}}}

\subsection{Pegue os pacotes de instalação necessário para instalação das gems, se for desenvolver para o gitlab, altere o env para RAILS\_ENV=development}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/bundle install --deployment --without development test mysql aws
}}}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/bundle exec rake gitlab:setup RAILS\_ENV=production
}}}

Escolha yes para criar as tabelas no banco

\emph{NOTA:}

\fbox{\parbox{\textwidth}{
\texttt{
Admin login and password -- login: admin@local.host -- password: 5iveL!fe
}}}

\subsection{Adicionar gitlab para iniciar com o sistema, esse passo não é requisito para o modo de desenvolvimento}

\fbox{\parbox{\textwidth}{
\texttt{
wget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/\\init/sysvinit/centos/gitlab-unicorn
}}}

\fbox{\parbox{\textwidth}{
\texttt{
chmod +x /etc/init.d/gitlab}}}

\fbox{\parbox{\textwidth}{
\texttt{
chkconfig --add gitlab
}}}

\fbox{\parbox{\textwidth}{
\texttt{
chkconfig gitlab on
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
service gitlab start
}}}

\subsection{Compile os asstes, para desenvolvimento altere o env para RAILS\_ENV=development}

\fbox{\parbox{\textwidth}{
\texttt{
sudo -u git -H /usr/local/bin/bundle exec rake assets:precompile RAILS\_ENV=production
}}}

\subsection{Altere as permissões dos grupos}

\fbox{\parbox{\textwidth}{
\texttt{
chmod g+rx /home/git/
}}}

Altere a linha:

\fbox{\parbox{\textwidth}{
\texttt{
env: enabled: true
}}}

Para:

\fbox{\parbox{\textwidth}{
\texttt{
env: enabled: false
}}}

Altere essas linhas:

\fbox{\parbox{\textwidth}{
\texttt{issues\_tracker: \# redmine: \# title: ``Redmine'' \#
\#\# If not nil, link `Issues' on project page will be replaced with
this \# \#\# Use placeholders: \# \#\# :project\_id - GitLab project
identifier \# \#\# :issues\_tracker\_id - Project Name or Id in external
issue tracker \# project\_url:
``http://redmine.sample/projects/:issues\_tracker\_id'' \# \# \#\# If
not nil, links from /\#\d/ entities from commit messages will replaced
with this \# \#\# Use placeholders: \# \#\# :project\_id - GitLab
project identifier \# \#\# :issues\_tracker\_id - Project Name or Id in
external issue tracker \# \#\# :id - Issue id (from commit messages) \#
issues\_url: ``http://redmine.sample/issues/:id'' \# \# \#\# If not nil,
links to creating new issues will be replaced with this \# \#\# Use
placeholders: \# \#\# :project\_id - GitLab project identifier \# \#\#
:issues\_tracker\_id - Project Name or Id in external issue tracker \#
new\_issue\_url:
``http://redmine.sample/projects/:issues\_tracker\_id/issues/new'' \# \#
jira: \# title: ``Atlassian Jira'' \# project\_url:
\\``http://jira.sample/issues/?jql=project=:issues\_tracker\_id'' \#
issues\_url: ``http://jira.sample/browse/:id'' \# new\_issue\_url:
``http://jira.sample/secure/CreateIssue.jspa''
}}}

Para:

\fbox{\parbox{\textwidth}{
\texttt{
issues\_tracker: redmine: title: ``Redmine'' \#\# If not nil, link
`Issues' on project page will be replaced with this \#\# Use
placeholders: \#\# :project\_id - GitLab project identifier \#\#
:issues\_tracker\_id - Project Name or Id in external issue tracker
project\_url: "http://redmine.sample/projects/:issues\_tracker\_id"
\#\# If not nil, links from /\# d/ entities from commit messages will replaced with this
\#\# Use placeholders:
\#\#  :project\_id        - GitLab project identifier
\#\#  :issues\_tracker\_id - Project Name or Id in external issue tracker
\#\#  :id                - Issue id (from commit messages)
issues\_url: "http://redmine.sample/issues/:id"
\#\# If not nil, links to creating new issues will be replaced with this
\#\# Use placeholders:
\#\#  :project\_id        - GitLab project identifier
\#\#  :issues\_tracker\_id - Project Name or Id in external issue tracker
new\_issue\_url: "http://redmine.sample/projects/:issues\_tracker\_id/issues/new"
\# jira:
\# title: "Atlassian Jira"
\# project\_url: \\"http://jira.sample/issues/?jql=project=:issues\_tracker\_id"
\# issues\_url: "http://jira.sample/browse/:id"
\# new\_issue\_url: "http://jira.sample/secure/CreateIssue.jspa"
   }}}
   
\emph{NOTA:} Altere todos redmine.sample para seu servidor redmine

\subsection{Restart gitlab}

\fbox{\parbox{\textwidth}{
\texttt{
sudo service gitlab restart
}}}

\emph{NOTA:}

\fbox{\parbox{\textwidth}{
\texttt{
Você pode acessar o gitlab usando essa url: `http://localhost:8090/gitlab
}}}