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:
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
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
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:
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
+---firstname.lastname@example.org (email@example.com, firstname.lastname@example.org, email@example.com)
Once dependencies are installed, you will be ready to run your app locally.
Create a new app
Follow these steps:
- Open website, go to Personal apps (left menu bar)
- Click ⨁ button to open New App interface
- 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
- Go to Settings page, in Environmental variables section click on Edit button.
- Choose ADD NEW VARIABLE
- In the Name field write BUILDPACK_URL
- In the VALUE field put
- Save settings
Deploy your app
- Go to Settings page, copy the app git url from the Git URL section.
- Switch to Dokkur Toolbelt and execute this command:
git remote add dokkur git_urlInstead of git_url paste your app's git url.
- Push your app:
git push dokkur masterIf 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.