AWS PaaS: Running Node.js with Dokku on an Ubuntu instance
Docker powered mini-Heroku. The smallest PaaS implementation you’ve ever seen.
During our initial testing we started out with a t1.micro instance, which seemed sufficient for development needs. The instance consumes a constant 100% CPU during operation, yet the different services respond in a timely fashion with a few megabytes of RAM to spare with two to three applications running. Definitely not the configuration we would use for a production environment.
VHOSTrecords. You can use any FQDN that will resolve using
dig +short $HOSTNAMEon your instance.
The domain you use for your Dokku server needs to support wildcard sub-domains.
An example has been provided below:
example.org A <Elastic IP> * A <Elastic IP>
Your server also needs to be able to respond to port 80, make sure that the Security Group for the server includes a rule that opens port 80 to
0.0.0.0/0 to ensure a proper working server.
Creating AWS Instance
Instantiate a new AWS instance using the Ubuntu 13.04 image. Once this process completes, go ahead and log into the instance via SSH as the user ubuntu.
Also create a new Elastic IP and assign it to your newly created instance. Modify your DNS as described above to point both the bare domain as well as the wildcard sub domain to the assigned Elastic IP.
/etc/hostname to this domain name and make sure to also change the server host name.
$ sudo cat "example.org" > /etc/hostname $ sudo hostname example.org
After following the steps above, run the following command line script as the user ubuntu:
$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
Dokku will begin installation, a process which usually takes less than five minutes to complete.
Once installation completes, Dokku will notify you to create a git key. Open a new terminal window on your local machine. Determine which SSH key to use for authentication. Most systems use either
id_rsa by default.
$ cat ~/.ssh/id_rsa.pub | ssh example.org "sudo gitreceive upload-key example"
Once you have added your key to the Dokku server you are ready to deploy your first application to your new PaaS!
Deploying Node.js to Dokku
Dokku supports Node.js as well as several other buildpacks. In order to deploy your application to your Dokku instance follow these simple steps.
$ cd node-js-sample $ git remote add example email@example.com:node-js-app $ git push example master
This will initialize the deployment process and bootstrap your Node.js application on your Dokku server.
Once your application has been deployed, it will start responding on http://node-js-app.example.org.
Please see the Dokku project on Github for more information.