Skip to content

Instantly share code, notes, and snippets.

@speier
Last active December 19, 2015 13:49
Show Gist options
  • 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. install node.js (https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)
14. create upstart script: `sudo nano /etc/init/project.conf` (see contents below)
15. add developers public key to `~/.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
sudo stop project
sudo start project
description "project daemon"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
chdir /home/git/project
exec /usr/bin/node server.js > /var/log/project.log 2>&1
`git remote add test [email protected]:project.git`
`git push test master`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment