Structure for your non-trivial node.js project.
Linux/OSX running node v0.6.x, mongodb & redis
-
Get the boilerplate:
mkdir projectname git clone git://github.com/hunterloftis/node-boilerplate.git projectname cd projectname
-
Check your system requirements and start local databases:
scripts/requirements redis-server mongod
-
Try it:
sudo npm install sudo node server
-
code, code, code
-
Set up a git repository hosting your project (eg, on Github)
Ubuntu VPS (eg, Linode)
-
Fill out
scripts/deploy.conf
- more -
Put your & other developers' public keys in
scripts/provisioning/keys
(these public keys will have root access) -
Provision your server as root:
cd scripts sudo ./provision staging root
-
Run within /scripts:
./deploy staging setup ./deploy -T staging
A sharp fork of visionmedia/deploy to be used for provisioning and deployment.
deploy(1)
will look for ./deploy.conf, consisting of one or more environments, [staging]
, [production]
, etc, followed by directives.
An example .conf file with all available directives:
[production]
project awesome
repo [email protected]:Skookum/awesome.git
host 123.456.789.10
private /keys/awesome.id_rsa
environment production
ref origin/master
stack node
[media]
project awesome_media
repo [email protected]:Skookum/awesome.git
host 123.456.789.11
private /keys/awesome.id_rsa
ref origin/master
stack nginx
The name of your project. This is also the username of your deploy user, and the location of your deployed project (/home/$projectname). Avoid using characters other than [a-z] and underscore.
project better_than_facebook
Your git repository. Deploying will pull from this uri as the deploy user, $projectname.
repo git://github.com/hunterloftis/node-boilerplate.git
The IP address of your server.
host 123.456.789.10
Path to your deploy user's private key. This is necessary if you are using a private git repository. If not, just use /dev/null.
private /keys/awesome.id_rsa
A string that sets NODE_ENV for this project.
environment staging
The default git ref from which to deploy. Defaults to origin/master.
ref origin/staging
One of: node
or nginx
.
The stack determines what type of server deployment you'd like to do. Node deploys a node server, while nginx deploys a very simple, fast, static file server that hosts your app/public
directory. It's designed to deploy media.yoursite.com.
stack node