Skip to content

Instantly share code, notes, and snippets.

@speier
Last active December 19, 2015 13:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speier/5964482 to your computer and use it in GitHub Desktop.
Save speier/5964482 to your computer and use it in GitHub Desktop.
experimenting with git powered deployment
01. `apt-get install git`
02. `adduser git`
03. `visudo` add `git ALL=(ALL:ALL) NOPASSWD: ALL` to user privilege specification
04. `login git`
05. `ssh-keygen -t rsa`
06. `mkdir project`
07. `mkdir project.git`
08. `cd project.git`
09. `git init --bare`
10. `cd hooks`
11. `nano post-receive` (see contents below)
12. `chmod +x post-receive`
13. `sudo apt-get update`
14. `sudo apt-get install python-software-properties python g++ make`
15. `sudo apt-get install software-properties-common`
16. `sudo add-apt-repository ppa:chris-lea/node.js`
17. `sudo apt-get update`
18. `sudo apt-get install nodejs`
19. create upstart script: `sudo nano /etc/init/project.conf` (see contents below)
20. add developers public key to `nano ~/.ssh/authorized_keys`
#!/bin/sh
APP_TREE=/home/git/project
GIT_WORK_TREE=$APP_TREE git checkout -f
cd $APP_TREE
npm install
# we have a few private packages on github, without versioning, those needs to be installed by name
# npm install xy-package
# trying to stop then start (unfortunately upstart's restart command doesn't have the same behaviour)
sudo stop project
sudo start project
description "project daemon"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
env NODE_ENV='production'
env STAGING='true'
chdir /home/git/project
exec /usr/bin/node server.js >> /var/log/project.log 2>&1
`git remote add test git@1.2.3.4:project.git`
`git push test master`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment