Navigation Menu

Skip to content

kevinnguy/dokku-aws-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dokku - AWS Tutorial

A tutorial on setting up Dokku on your local machine via Vagrant and on AWS EC2. Thanks to this article for teaching me how to do this.

Installation

  1. Clone the Dokku repo to your local machine
    git clone git@github.com:dokku/dokku.git

  2. Install Vagrant (I suggest installing via brew cask)
    brew cask install vagrant

  3. Install VirtualBox in order to set up Vagrant
    brew cask install virtualbox

  4. (Optional) I would also install Vagrant Manager to manage your Vagrant machines
    brew cask install vagrant-manager

Set up project for Dokku

For this tutorial, I'm going to use an Express app as an example. You can clone the example app repo here.

The folder name should be express-example and we will use this name as our project name for the tutorial.

Set up Dokku on your local Vagrant machine

  1. Create the Vagrant virtual machine by changing directory to your local Dokku repo
    cd /path/to/local/dokku

  2. Create a Vagrant virtual machine with Dokku!
    vagrant up

  3. You want to set the local IP (default is 10.0.0.2) of your Vagrant machine in your /etc/hosts file and pick a hostname. For this tutorial, we will use the hostname dokku.me
    10.0.0.2 dokku.me

Finish setting up Dokku on your local Vagrant machine

  1. Access dokku.me on your browser.
    browser

  2. Paste your ssh public key, found at ~/.ssh/id_rsa.pub. This ssh public key should be the same key you used to clone the example app.

  3. Set Hostname to dokku.me

  4. Check Use virtualhost naming for apps This will allow you to access <project-name>.dokku.me

  5. Edit your /etc/hosts file and add another host
    10.0.0.2 express-example.dokku.me

Set up project for Dokku (Part 2)

  1. Add the new Dokku instance as a git remote to our example app so we can start pushing changes locally to Dokku on our local Vagrant virtual machine. git remote add local dokku@dokku.me:express-example

  2. Make a change to your view in the Express example app and push your changes
    git push local master

We're half way there!

Now we're going to set up Dokku on our AWS EC2 server so we can push our changes remotely to our server.

Set up AWS

  1. Launch a new instance for EC2.

  2. From the Quick Start page, select the Ubuntu Server machine image.
    aws

  3. Select any instance type. For this tutorial, you probably want to select the t2.micro type, since it is eligible for free tier users.

  4. Configure your security group by adding types:

    • SSH on port 22
    • HTTP on port 80
    • (Adding TCP on port range 20000-65535 might be necessary too) security
  5. Launch your new instance and download the .pem file for ssh access.

  6. Once you have launched your instance, get it's public IP and add it to your /etc/hosts file. We will use the hostname dokku.aws.me
    <instance's public IP> dokku.aws.me

Set up Dokku on your EC2 instance

  1. SSH into your EC2 instance
    ssh -i /path/to/file.pem ubuntu@dokku.aws.me

  2. Install Dokku via wget
    wget https://raw.githubusercontent.com/progrium/dokku/v0.4.5/bootstrap.sh
    sudo DOKKU_TAG=v0.4.5 bash

  3. Once Dokku is installed, access dokku.aws.me on your browser.
    browser

  4. Paste the same ssh public key as before, from ~/.ssh/id_rsa.pub

  5. Set Hostname to dokku.aws.me

  6. Check Use virtualhost naming for apps

  7. Add another hostname to your /etc/hosts file.
    <instance's public IP> express-example.dokku.aws.me

Set up project for Dokku (Part 3)

  1. Add the EC2 instance as a git remote to our example app so we can start pushing changes remotely to Dokku on our EC2 Ubuntu server.
    git remote add aws dokku@dokku.aws.me:express-example

  2. Make a change to your view in the Express example app and push your changes
    git push aws master

We're done!

You can now see your changes on http://express-example.dokku.aws.me! By having Dokku set up on our local machine via Vagrant and on EC2, we now have two environments to push and deploy our app.

I'm still learning how to use Dokku so if there are any errors, please let me know!

About

A tutorial on setting up Dokku on your local machine via Vagrant and AWS EC2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published