Introduction

This tutorial will show you how to deploy your Node.js app in several minutes. These instructions will also give you enough information to make the most out of Dokkur.

Be sure that you already have:

  1. Dokkur account.
  2. SSH keys added to your account.
  3. Node.js and npm installed locally.

Set up

In this step you will install the Dokkur Toolbelt that gives you you access to the Dokkur Command Line Interface (CLI).

After installation you can use dokkur login command to log in with your email and password you set when creating Dokkur account.

Before you continue, check that you have the prerequisites installed properly. Type each command below and make sure it displays the version you have installed. (Your versions might be different from the example.) If no version is returned, go back to the introduction of this tutorial and install the prerequisites.

All of the following local setup will be required to complete the “Declare app dependencies” and subsequent steps.

This tutorial will work for any version of Node greater than 4 or so - check that it’s there:

$ node -v
v5.9.1

npm is installed with Node, so check that it’s there. If you don’t have it, install a more recent version of Node:

$ node -v
3.7.3

Now check that you have git installed. If not, install it and test again.

$ git --version
git version 2.2.1

Prepare the app

To deploy an app you need to have the app prepared for deployment.

If you don’t have your own Node.js project, you can use a template that we have already prepared for you:

$ git clone https://github.com/dokkur/node-js-getting-started.git
$ cd node-js-getting-started

If you have a Node.js app that you want to deploy, you need to do some preparations.

Declare app dependencies

How does Dokkur recognize an app as a Node.js app? The answer is by the existence of a package.json file in the root directory. You can create it by running npm init --yes.

It may look something like this:

{
"name": "node-js-getting-started",
"version": "0.2.5",
...
"engines": {
"node": "5.9.1"
},
"dependencies": {
"ejs": "2.4.1",
"express": "4.13.3"
},
...
}

The package.json is not only a specification of which dependencies should be installed with your application, but also a file that determines the version of Node.js that will be used to run your application on Dokkur. When an app is deployed, Dokkur reads this file and installs the appropriate node version together with the dependencies using the npm install command.

Now run npm install in your local directory to install the dependencies, preparing your system for running the app locally:

$ npm install
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/stream-spigot
npm http GET https://registry.npmjs.org/connect/2.12.0
...
express@4.13.3 node_modules/express
+---methods@0.1.0
+---merge-descriptors@0.0.1
+---range-parser@0.0.4
+---cookie-signature@1.0.1
+---debug@2.0.0
+---fresh@0.2.0
+---buffer-crc32@0.2.1
+---cookie@0.1.0
+---mkdirp@0.3.5
+---send@0.9.2 (destroy@1.0.3, ms@0.6.2, mime@1.2.11)
...

Once dependencies are installed, you will be ready to run your app locally.

Create a new app

Follow these steps:

  1. Open website, go to Personal apps (left menu bar)
  2. Click ⨁ button to open New App interface
  3. Enter the app’s name (Caution! Use latin lowercase and numbers, e.g. myapp007), choose available and convenient instances for hosting, pick Custom App template and press Create App button.

Congrats! Your app has easily been created. Now you need to deploy it. Just do it!

Add BUILDPACK_URL config var

  1. Go to Settings page, in Environmental variables section click on Edit button.
  2. Choose ADD NEW VARIABLE
  3. In the Name field write BUILDPACK_URL
  4. In the VALUE field put
    https://github.com/dokkur/buildpack-nodejs
  5. Save settings

Deploy your app

  1. Go to Settings page, copy the app git url from the Git URL section.
  2. Switch to Dokkur Toolbelt and execute this command:

    git remote add dokkur git_url
    Instead of git_url paste your app's git url.

  3. Push your app:
    git push dokkur master
    If you want to deploy another branch, run:
    git push dokkur yourbranch:master

Hell yeah! Your app is deployed! Open yourappname.dokkurapp.com in your browser.