Forked from mr4torr/Deploy com o git - git --bare with Ruby on Rails
Last active
May 16, 2018 19:40
-
-
Save xikaos/47a6fb5fa4a8a0b7da9fd07e68ae0590 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Entrar no servidor e fora da pasta do projeto | |
$ git init --bare repo | |
Criar hooks post-receive | |
$ cd repo/hooks | |
$ nano post-receive | |
## Adicionar no arquivo | |
``` | |
#!/bin/sh | |
git --work-tree=/home/rails/site --git-dir=/home/user/repo checkout -f | |
``` | |
$ chmod +x post-receive | |
> /home/rails/site = pasta aonde esta o projeto | |
> /home/repo/site.git = repositorio git | |
$ vim post-update | |
## Adicionar no arquivo | |
``` | |
#!/bin/sh | |
APP_PATH=/home/rails/balada | |
export RAILS_ENV="production" | |
export PATH="/usr/local/rvm/gems/ruby-2.2.2/bin:/usr/local/rvm/rubies/ruby-2.2.2/bin:$PATH" | |
export GEM_PATH="/usr/local/rvm/gems/ruby-2.2.2:$GEM_PATH" | |
BUNDLE=/usr/local/rvm/gems/ruby-2.2.2/bin/bundle | |
cd ${APP_PATH} | |
echo '~> Post Update ============================' | |
echo '- Bundle Install' | |
RAILS_ENV=production $BUNDLE install | |
echo '- DB Migration' | |
RAILS_ENV=production $BUNDLE exec rake db:migrate | |
echo '- Assets Precompile' | |
RAILS_ENV=production $BUNDLE exec rake assets:precompile | |
echo '- Assets Sync' | |
RAILS_ENV=production $BUNDLE exec rake assets:sync | |
echo '- Create folder tmp' | |
mkdir -p tmp/ | |
echo '- Create file restart' | |
touch tmp/restart.txt | |
``` | |
$ chmod +x post-update | |
# Adicione ou altere no arquivo /etc/ssh/sshd_config | |
``` | |
PermitUserEnvironment yes | |
``` | |
# Variaveis globais colocar no arquivo /etc/environment | |
# Adicione os path da versao do ruby | |
``` | |
env | grep -E "^(GEM_HOME|PATH|RUBY_VERSION|MY_RUBY_HOME|GEM_PATH)=" > ~/.ssh/environment | |
``` | |
# reinicie o ssh | |
``` | |
sudo /etc/init.d/ssh restart | |
``` | |
# no servidor local | |
git remote add production ssh://[email protected]/home/repo/site.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment