📜 ⬆️ ⬇️

Deploying Nodejs DotCloud Applications

Intro

Dotcloud is a cloud-based application deployment platform. The stack on DotCloud includes more than 10 different services among which there is Node.JS.

My first impressions of DotCloud were very positive. You can almost forget about how to deploy the application and focus entirely on the code. Deployment work comes down to installing the DotCloud CLI and configuring the dotcloud.yml environment file . Installing a client under Linux / MacOS is trivial:
sudo easy_install pip && sudo pip install dotcloud

Preparing for deployment

To deploy an application to Dotcloud, you need a dotcloud.yml file that describes the services to which the application will have access. The full list of applications can be viewed at the link . To access the Node.JS + Redis stack, the dotcloud.yml file can be as follows:
www:
type: nodejs

data:
type: redis

If the application on Node.JS uses additional packages, you can use the package.json file, in which you specify dependencies on other packages. Packages will be automatically installed during deployment. Sample package.json file:
{
"engines" : {
"node" : ">=v0.4.5"
},
"dependencies" : {
"redis" : ">=0.6.6" ,
"express" : ">=2.4.2"
}
}

To automatically launch applications on Node.JS, you need to create a third file called supervisord.conf and specify the launch path in it
[program:node]
command = node index.js
directory = /home/dotcloud/current


Using environment.json

To access the stack of services that were specified in the dotcloud.yml file is very simple. After the application is deployed to the home directory, an environment.json file is created containing information for accessing services. Using this file, you can configure the application to automatically use the settings for the databases without worrying about manual configuration. Since I specified Redis as a database in the dotcloud.yml file and named it data , to obtain the settings for Redis from the application on Node.JS, it is enough to write:
var envfilepath = '/home/dotcloud/environment.json' ,
environment = JSON.parse(require( 'fs' ).readFileSync(envfilepath));

var host = environment[ 'DOTCLOUD_DATA_REDIS_HOST' ],
port = environment[ 'DOTCLOUD_DATA_REDIS_PORT' ],
pass = environment[ 'DOTCLOUD_DATA_REDIS_PASSWORD' ];

Deployment

To create an application on Dotcloud, you need to write in the console:
dotcloud create appname
( appname - in this case, the name of the application, which can be any)
Well, directly push applications on Dotcloud
dotcloud push appname ~/path-to-node-app/
If successful, they will issue a www address to access the application.
Deployment finished successfully. Your application is available at the following URLs
www: d07c100d.dotcloud.com

What else can you do

Use your own domain name.
To do this, you need to register the DNS record of the CNAME gateway.dotcloud.com. for the corresponding domain. And add alias to your Dotcloud application:
dotcloud alias add appname.www www.example.com
You can also connect via SSH
dotcloud ssh appname.www

A complete list of commands can be obtained in the detailed documentation on the official website.

')

Source: https://habr.com/ru/post/125375/


All Articles