Skip to content

Files

Latest commit

 

History

History

linode

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Linode Setup

linode-logo

If you are new to Linode, please signup using the following link1: https://www.linode.com/?r=5b426b2a0a026ebcf71261b824fa3a0ff3a6f82d and use promo code DOCS10 for $10 credit on your new account.

Signed up: image image

Create a Virtual Machine "Instance"

There are two options for creating a Virtual Machine (VM): (A) Manually and (B) Automated.

A. Manual (Click-to-Create)

#### Step 1: Select an instance type

image

Once you've launched the instance, you should see the Linode Manager: image

Step 2: Select the Operating System

Select an Operating System (we tend to use the most recent Ubuntu "LTS" version):
image

Step 3: Boot the New Instance

Remember to click on [Boot] button to actually run the instance: image

Step 4: Add your SSH Key to the Linode

Click on the "Dashboard" link for your VM: 04-linode-manager-click-dashboard

Click on "Remote Access" then click on "Launch Lish Console": 05-linode-manager-dashboard-remote-access-click-lish

Use "Lish Console" to add public ssh key to the node: image

Now can login from localhost using ssh using public key: image

SSH using RSA Key: https://www.linode.com/docs/security/use-public-key-authentication-with-ssh

B. Automated Virtual Machine Provisioning using Vagrant

For the next section we are using Vagrant to (automate) "provisioning" a VM. If you are new to Vagrant, please see: github.com/dwyl/learn-vagrant

Step 1: Create a Linode API Key

Login to your Linode account and visit My Profile > API Keys then create a new key:

02-linode-profile-api-keys-named

You should see something like this:

03-linode-profile-api-keys-named-display

Don't worry, this is not a "epic security fail" ... the key is not active, it's just for illustrative purposes.

Step 2: Copy the API Key (to a Safe Place) and Export as Environment Variable

Copy the newly created API Key to a safe place (your choice of key storage) and then export it as an Environment Variable:

In your terminal window type export LINODE_API_KEY= and paste your API Key:

export LINODE_API_KEY=aKiuRAOe5WEgnIaGouhWz19jJSInnwQzx8wOdSlAIEMkk4Z8cXGQQHQBdB2MSaRk

confirm that Environment Variable was set by running printenv and checking the output.

Note: if you are new to using Environment Variables, please see: github.com/dwyl/learn-environment-variables

#### Step 3: Install the Linode Vagrant Plugin

Once you have installed Vagrant you will need to install the vagrant-linode plugin:

vagrant plugin install vagrant-linode

you should see:

Installing the 'vagrant-linode' plugin. This can take a few minutes...
Installed the plugin 'vagrant-linode (0.2.8)'!

Following this guide: https://www.linode.com/docs/applications/configuration-management/vagrant-linode-environments

Step 4: Create a Vagrantfile

Create a Vagrantfile for your project and copy-paste the contents of the sample:

Step 5: Launch a Linode VM using Vagrant

vagrant up --debug &> vagrant.log

Note: that command will output the steps the vagrant up command to vagrant.log so you can monitor it's progress (eventual success/failure). Rememver to add the vagrant.log to your .gitignore file as it's thousands of lines which change each time an instance is created. e.g:

echo "vagrant.log >> .gitignore"

You should see something similar to: vagrant-up Once the vagrant up command has completed provisioning the Linode VM, login to the VM using the command:

vagrant ssh

that will give you the IP Address of the Vagrant Box, which in our case is: 213.168.248.157

If you visit the IP address in a browser you will see a 502 error:

nginx-502-error

That is a good thing because it tells you that NGiNX is working! (the 502 is because we don't have a Phoenix app running on port 4000, yet!)

Step 6: Build, Deploy & Start a Phoenix App using Edeliver

git clone git@github.com:nelsonic/hello_world_edeliver.git
cd hello_world_edeliver

Open the .deliver/config file and update:

  • BUILD_HOST (IP Address)
  • BUILD_USER
  • PRODUCTION_USER

to the values you need. In our case I updated the values to:

BUILD_HOST="213.168.248.157"
BUILD_USER="ubuntu"
BUILD_AT="/home/ubuntu/hello_world_edeliver/builds"

PRODUCTION_HOSTS="213.168.248.157"
PRODUCTION_USER="ubuntu"
DELIVER_TO="/home/ubuntu"

see: .deliver/config#L3-L9

Now run the edeliver commands to build, deploy and start

mix edeliver build release --verbose --branch=continuous-delivery
mix edeliver deploy release to production --verbose
mix edeliver start production

You should see: edeliver-deploy-start

And when you refresh the browser page you should see the Phoenix App! phoenix-linode-working

So now we have a working server running a Phoenix App on Linode!