Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mr4torr/e2d41b14fe62ab7ff07ce22e6b145d80 to your computer and use it in GitHub Desktop.

Select an option

Save mr4torr/e2d41b14fe62ab7ff07ce22e6b145d80 to your computer and use it in GitHub Desktop.

Revisions

  1. mr4torr renamed this gist Jan 30, 2018. 1 changed file with 0 additions and 0 deletions.
  2. mr4torr revised this gist May 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Deploy com o git - git --bare
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ $ vim post-update
    #!/bin/sh

    APP_PATH=/home/rails/balada
    export RAILS_EN="production"
    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
  3. mr4torr revised this gist May 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Deploy com o git - git --bare
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ $ vim post-update

    APP_PATH=/home/rails/balada
    export RAILS_EN="production"
    export PATH="/usr/local/rvm/gems/ruby-2.2.2/bin:$PATH"
    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

  4. mr4torr revised this gist May 6, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions Deploy com o git - git --bare
    Original file line number Diff line number Diff line change
    @@ -34,16 +34,16 @@ cd ${APP_PATH}
    echo '~> Post Update ============================'

    echo '- Bundle Install'
    $BUNDLE install RAILS_ENV=production
    RAILS_ENV=production $BUNDLE install

    echo '- DB Migration'
    $BUNDLE exec rake db:migrate RAILS_ENV=production
    RAILS_ENV=production $BUNDLE exec rake db:migrate

    echo '- Assets Precompile'
    $BUNDLE exec rake assets:precompile RAILS_ENV=production
    RAILS_ENV=production $BUNDLE exec rake assets:precompile

    echo '- Assets Sync'
    $BUNDLE exec rake assets:sync RAILS_ENV=production
    RAILS_ENV=production $BUNDLE exec rake assets:sync

    echo '- Create folder tmp'
    mkdir -p tmp/
  5. mr4torr revised this gist May 6, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Deploy com o git - git --bare
    Original file line number Diff line number Diff line change
    @@ -61,6 +61,8 @@ $ chmod +x post-update
    PermitUserEnvironment yes
    ```

    # Variaveis globais colocar no arquivo /etc/environment

    # Adicione os path da versao do ruby

    ```
  6. mr4torr revised this gist May 6, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions Deploy com o git - git --bare
    Original file line number Diff line number Diff line change
    @@ -67,6 +67,12 @@ PermitUserEnvironment yes
    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
  7. mr4torr revised this gist May 6, 2017. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions Deploy com o git - git --bare
    Original file line number Diff line number Diff line change
    @@ -55,5 +55,18 @@ touch tmp/restart.txt

    $ chmod +x post-update

    # Adicione ou altere no arquivo /etc/ssh/sshd_config

    ```
    PermitUserEnvironment yes
    ```

    # Adicione os path da versao do ruby

    ```
    env | grep -E "^(GEM_HOME|PATH|RUBY_VERSION|MY_RUBY_HOME|GEM_PATH)=" > ~/.ssh/environment
    ```


    # no servidor local
    git remote add production ssh://[email protected]/home/repo/site.git
  8. mr4torr created this gist Jul 25, 2016.
    59 changes: 59 additions & 0 deletions Deploy com o git - git --bare
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    # 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_EN="production"
    export PATH="/usr/local/rvm/gems/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'
    $BUNDLE install RAILS_ENV=production

    echo '- DB Migration'
    $BUNDLE exec rake db:migrate RAILS_ENV=production

    echo '- Assets Precompile'
    $BUNDLE exec rake assets:precompile RAILS_ENV=production

    echo '- Assets Sync'
    $BUNDLE exec rake assets:sync RAILS_ENV=production

    echo '- Create folder tmp'
    mkdir -p tmp/

    echo '- Create file restart'
    touch tmp/restart.txt

    ```

    $ chmod +x post-update

    # no servidor local
    git remote add production ssh://[email protected]/home/repo/site.git