Live data from Hacker News

Simple deployment with git

rous.info

1–4 of 4 posts

Re: Simple deployment with git

#3
You can avoid pulling the repo everytime if you create a hook. In Ubuntu real quick, with default LAMP stack:

    git init --bare --shared=group /srv/git/app.git
    mkdir /var/www/app
    chown -R www-data:www-data /srv/git/app.git /var/www/app
    chmod -R g+rw /srv/git/app.git /var/www/app
    vim /srv/git/app.git/hooks/post-receive
      #!/bin/sh
      export GIT_WORK_TREE=/var/www/app
      git checkout -f dev # dev branch
      cd /var/www/app
      # Run composer, npm, etc...
    chmod +x /srv/git/app.git/hooks/post-receive
Whenever you push it'll checkout the dev branch in your public web folder. Now, that's instant deployment!

Re: Simple deployment with git

#4
post #3

You can avoid pulling the repo everytime if you create a hook. In Ubuntu real quick, with default LAMP stack: git init --bare --shared=group /srv/git/app.git mkdir /var/www/app chown -R www-data:www-data /srv/git/app.git /var/www/app chmod -R g+rw /srv/git/app.git /var/www/app vim /srv/git/app.git/hooks/post-receive #!/bin/sh export GIT_WORK_TREE=/var/www/app git checkout -f dev # dev branch cd /var/www/app # Run com…

This is quite beneficial if you want all of your pushes deployed instantly (as is the case in the post).

This was just a little post using pull as the simplest example possible. It's a part of a toy project I'm working on and I didn't want to go in too deep...