How deploy Node app to Ubuntu

August 10, 2013 6.3k views
I installed node, npm and mongodb on my dropplet and now wondering how to deploy my local node app to the server.
13 Answers
Create a user for the app:

adduser app

SSH in as app:

ssh app@yourdroplet'sIPaddress

Upload your files to your home directory (or clone the git repo), run "npm install" in the app's directory and edit the configuration files to connect properly to mongodb. Once you're done, run your app:
node start.js

node app.js

Keep in mind the filename varies from app to app.
I added new user, installed git, init git and added github repo as origin, added ssh key (local machine), now how do I authorize to pull from my github repo? If created new username does it mean all files will be accessible from mydomain.com/appuser ?

@abachuk: Is it a private github repo?
yes, it's private repo. It doesn't have to be github, I just want to push changes from local computer to DO server, I like how heroku gives you git repo, so I can push to heroku and github at the same time.
Run this command as the app user:

ssh-keygen -t rsa -N ''

Press enter if it asks you where to store the key pair.

Add the public key as a deploy key in your github repo:

cat ~/.ssh/id_rsa.pub

Then clone the git repo:

cd ~

git clone git@github.com:user/privateRepo.git
Thanks. Getting this error.

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Is there a way to create repo on DO droplet like git@myrepo@123.345.456.11.git and push my code from my computer directly to DO repo ?

Thanks for your help, again!
Did you add your server's public key to your github repo?
I will try that. What about setting up repo on DO droplet and use it to push changes from local computer instead of pulling from github repo every time I do any changes. Thanks.
@abachuk: We have an article on that coming soon however it doesn't cover restarting the nodejs application on push but shouldn't be too hard to add.
ok, great. I'll wait for the article then. Thanks.
I was able to set up git repo (/app/myappname.git) and push my code there, however after I pushed it, I don't see it remotely. When I set up new local repo and clone remote (app/myappname.git) repo - all code gets copied, so it's somewhere on the server, where is it and what URL it has in the browser (after I start node and do npm install) ? Thanks.
@abachuk: You can set up a private git repo on your droplet and push to it:


Also read my reply to Leo's comment on that article.
by Brian Rogers
This tutorial will show you how to set up a fully fledged Git server using SSH keys for authentication.
Have another answer? Share your knowledge.