Coder Social home page Coder Social logo

dokku-aws-tutorial's Introduction

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 [email protected]: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 [email protected]: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
      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 [email protected]

  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 [email protected]: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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.