├── 1.png ├── 2.png ├── 3.png └── README.md /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinnguy/dokku-aws-tutorial/dfcb67c60f0c21fc6f96cec97cbd5502f71b92b1/1.png -------------------------------------------------------------------------------- /2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinnguy/dokku-aws-tutorial/dfcb67c60f0c21fc6f96cec97cbd5502f71b92b1/2.png -------------------------------------------------------------------------------- /3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinnguy/dokku-aws-tutorial/dfcb67c60f0c21fc6f96cec97cbd5502f71b92b1/3.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dokku - AWS Tutorial 2 | A tutorial on setting up Dokku on your local machine via Vagrant and on AWS EC2. Thanks to [this article](https://medium.com/@alfeto/dokku-on-vagrant-and-aws-with-postgres-8a591bb48f51) for teaching me how to do this. 3 | 4 | ## Installation 5 | 1. Clone the [Dokku repo](https://github.com/dokku/dokku) to your local machine 6 | `git clone git@github.com:dokku/dokku.git` 7 | 8 | 2. Install [Vagrant](https://docs.vagrantup.com) (I suggest installing via [brew cask](https://caskroom.github.io/)) 9 | `brew cask install vagrant` 10 | 11 | 3. Install [VirtualBox](https://www.virtualbox.org) in order to set up Vagrant 12 | `brew cask install virtualbox` 13 | 14 | 4. (Optional) I would also install [Vagrant Manager](http://vagrantmanager.com) to manage your Vagrant machines 15 | `brew cask install vagrant-manager` 16 | 17 | ## Set up project for Dokku 18 | For this tutorial, I'm going to use an Express app as an example. You can clone the example app repo [here.](https://github.com/kevinnguy/express-example) 19 | 20 | The folder name should be `express-example` and we will use this name as our project name for the tutorial. 21 | 22 | ## Set up Dokku on your local Vagrant machine 23 | 1. Create the Vagrant virtual machine by changing directory to your local Dokku repo 24 | `cd /path/to/local/dokku` 25 | 26 | 2. Create a Vagrant virtual machine with Dokku! 27 | `vagrant up` 28 | 29 | 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` 30 | `10.0.0.2 dokku.me` 31 | 32 | ## Finish setting up Dokku on your local Vagrant machine 33 | 1. Access [dokku.me](http://dokku.me) on your browser. 34 | ![browser](1.png "browser") 35 | 36 | 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. 37 | 38 | 3. Set `Hostname` to `dokku.me` 39 | 40 | 4. Check `Use virtualhost naming for apps` This will allow you to access `.dokku.me` 41 | 42 | 5. Edit your `/etc/hosts` file and add another host 43 | `10.0.0.2 express-example.dokku.me` 44 | 45 | ## Set up project for Dokku (Part 2) 46 | 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. 47 | `git remote add local dokku@dokku.me:express-example` 48 | 49 | 2. Make a change to your view in the Express example app and push your changes 50 | `git push local master` 51 | 52 | # We're half way there! 53 | Now we're going to set up Dokku on our AWS EC2 server so we can push our changes remotely to our server. 54 | 55 | ## Set up AWS 56 | 1. Launch a new instance for EC2. 57 | 58 | 2. From the Quick Start page, select the Ubuntu Server machine image. 59 | ![aws](2.png "aws") 60 | 61 | 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. 62 | 63 | 4. Configure your security group by adding types: 64 | - `SSH` on port `22` 65 | - `HTTP` on port `80` 66 | - (Adding `TCP` on port range `20000-65535` might be necessary too) 67 | ![security](3.png "security") 68 | 69 | 5. Launch your new instance and download the `.pem` file for ssh access. 70 | 71 | 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` 72 | ` dokku.aws.me` 73 | 74 | ## Set up Dokku on your EC2 instance 75 | 1. SSH into your EC2 instance 76 | `ssh -i /path/to/file.pem ubuntu@dokku.aws.me` 77 | 78 | 2. Install Dokku via `wget` 79 | `wget https://raw.githubusercontent.com/progrium/dokku/v0.4.5/bootstrap.sh` 80 | `sudo DOKKU_TAG=v0.4.5 bash` 81 | 82 | 3. Once Dokku is installed, access [dokku.aws.me](http://dokku.aws.me) on your browser. 83 | ![browser](1.png "browser") 84 | 85 | 4. Paste the same ssh public key as before, from `~/.ssh/id_rsa.pub` 86 | 87 | 5. Set `Hostname` to `dokku.aws.me` 88 | 89 | 6. Check `Use virtualhost naming for apps` 90 | 91 | 7. Add another hostname to your `/etc/hosts` file. 92 | ` express-example.dokku.aws.me` 93 | 94 | ## Set up project for Dokku (Part 3) 95 | 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. 96 | `git remote add aws dokku@dokku.aws.me:express-example` 97 | 98 | 2. Make a change to your view in the Express example app and push your changes 99 | `git push aws master` 100 | 101 | # We're done! 102 | You can now see your changes on [http://express-example.dokku.aws.me](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. 103 | 104 | I'm still learning how to use Dokku so if there are any errors, please let me know! 105 | 106 | --------------------------------------------------------------------------------