Last active
May 16, 2018 18:48
-
-
Save mr4torr/e2d41b14fe62ab7ff07ce22e6b145d80 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 | |
$ cd /home | |
$ mkdir repo && cd repo | |
$ mkdir site.git && cd site.git | |
$ git init --bare | |
$ cd hooks | |
$ vim post-receive | |
## Adicionar no arquivo | |
``` | |
#!/bin/sh | |
git --work-tree=/home/rails/site --git-dir=/home/repo/site.git checkout -f | |
``` | |
$ chmod +x post-receive | |
> /home/rails/site = pasta aonde esta o projeto | |
> /home/repo/site.git = pasta aonde ficara o hook do 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