-
-
Notifications
You must be signed in to change notification settings - Fork 499
Helpy on Digital Ocean Droplet with Docker on Ubuntu Tutorial
11/24/2018
How To Install Helpy on a Digital Ocean Droplet Using the One Click Image for Ubuntu 16.04 and Docker
Note: This same procedure has been tested on the newer Digital Ocean One Click Image for Ubuntu 18.04 and Docker
This tutorial was originally written for Digital Ocean. It contains some basic procedures that many of you will be familiar with already. Skip any section that you feel you have already knowledge of.
Docker is a software container platform used to run and manage apps in isolated side-by-side containers. Docker > “containers are a way to package software in a format that can run isolated on a shared operating system. Unlike VMs, containers do not bundle a full operating system - only libraries and settings required to make the software work are needed.” More information can be accessed on the Docker.com website, specifically, the What Is Docker ( https://www.docker.com/what-docker) page. In this tutorial, we will setup Helpy on a Digital Ocean droplet using one of the One Click Images available during Droplet creation or rebuilding. The One Click Image that we will create our droplet from will be pre-configured with Docker and will provide a platform for a quick installation of the Helpy software so that you can evaluate and/ or deploy it.
To create the Docker Droplet, log into your Digital Ocean account (or sign up for an account if you do not already have one) and select the Create Droplet option. Once you select this option, you will be brought to the Create Droplets page. First, select the Distribution category for Ubuntu 16.04 in the “Choose An Image” section of the page. Next, choose the link called One-Click Apps to the right of the Distributions Link. From there, select the Docker Image called Docker 17.06.1-ce on 16.04. This is an image for the 17.06.1 version of Docker Community Edition (the ‘-ce’ indicates it’s a Community Edition) on Ubuntu 16.04.
Next, on the same page, in the Choose A Size section of the page, choose a size for your droplet. We recommend the 2Gb RAM/ 40 Gb SSD Droplet size at a minimum for this particular installation. Choose a Data Center region as well as any additional options you would like to have on the droplet as well as Add an SSH key and Assign a Hostname for the Droplet you are about to create. Select the Create button and your droplet will be created.
The next step is to connect to your newly created/ imaged droplet. Do this through SSH utilizing one of the methods described in the How to Connect to Your Droplet with SSH (https://www.digitalocean.com/community/tutorials/how-to-connect-to-your-droplet-with-ssh) if you are not already familiar with connecting to a Droplet. After connecting to a newly created/ imaged Droplet for the first time, you will need to enter in the temporary password that has been emailed to you during the droplet creation or re-imaging process. You will have to change this password to another one which you will use from this point forth unless you decide to change it. It is the password for the ’root’ user.
Once you have assigned a password to the ‘root’ user, you will need to create a new user that will function as the Administrator for the Helpy system. In this tutorial, we will call that user ‘helpyadmin’ and it will be assigned to part of the super users group so it can utilize the ‘sudo’ command prefix.
Create your Helpy Administrator user using the instructions at the How to Create a Sudo User on Ubuntu Quickstart tutorial page. (https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart)
If you have not already done so for the creation of the Helpy Administrator user, switch to the newly created user as follows:
su helpyadmin
Note: In this tutorial our Helpy Administrator user is called ‘helpyadmin’ and we will use that user from this point forward for all commands. ‘su’ is the command for switch user.
Change the current directory to the base directory:
cd /
The next step is to clone the Helpy Repository (repo) from github to your droplet. You can approach this in two ways. You can clone directly from the master repo or create your own github account if you do not have one already and make a branch off of the master as your own. In this tutorial, we will be cloning from the master repo.
Since you will need super user permissions for the clone command and other commands to follow, preface the command with the ‘sudo’ command where shown. So to clone the repo you will enter:
sudo git clone https://github.com/helpyio/helpy.git
The Helpy repo will be cloned to your droplet.
After the cloning, it is a good idea to list the files that were cloned to ensure everything went as expected and to also get acclimated to the helpy directory folders and files. First list the folders and files in the base directory:
sudo ls -a /
Note: ‘ls’ is the command to list files and directories. As is the case with other commands on Ubuntu, you can get information on the ‘ls’ command by referencing the manual as follows:
man ls
Among other files and folders in the base directory that you have listed will be one named ‘helpy’. This folder is the cloned folder from github. To get acclimated to the files and folders in the ‘helpy’ folder, execute the following command:
sudo ls -a /helpy
The next step we will perform is to just check out the docker-compose directory using the Ubuntu ‘locate’ command.
For the ‘locate’ command to work, you’ll need to execute a command first in order to update the indexing database:
sudo updatedb
Then use the locate command to locate the docker-compose directory:
sudo locate docker-compose
Note: This step is not necessary to run docker-compose, it was just performed to show you the location of the files using the ‘locate’ command
To ensure that your docker environment is running properly, you can run the ‘hello-world’ application with docker:
sudo docker run hello-world
After receiving confirmation that your docker environment is operating properly, you are ready to proceed with the next step.
You’ll need to create a .env file in the /helpy/docker folder. In preparation for this, you will need two things:
- Password of your choice for POSTGRES User
- POSTGRES Secret Key Base
For the Password, come up with a password that you wish to use. For the secret key base, we’ll use the ‘openssl’ command that is on this Droplet image, to generate a random 64 bit hexadecimal key as follows:
cd /
sudo openssl rand -hex 64
You will be presented with a long string of numbers that you need to copy in it’s entirety to your clipboard or other location.
Now switch to the docker folder located within the /helpy folder:
cd /helpy/docker
Now, you’ll need to create a .env file called ‘.env’ within the docker folder as follows:
sudo nano .env
Note: You can reference the file called ‘.env.sample’ located in our current folder. The .env file in it’s entirety should be as follows, where the POSTGRES_PASSWORD= the password you came up with and the SECRET_KEY_BASE= the 64 bit hexadecimal key created in the step above where we ran the ‘openssl’ command.
POSTGRES_DB=helpy_production
POSTGRES_USER=helpy
POSTGRES_PASSWORD=yourpassword
SECRET_KEY_BASE=64bit hexadecimal key created using openssl command
Save the file by exiting nano and choosing to save the file. You can confirm the file contents are correct by rerunning the same command while still within this directory:
sudo nano .env
Note: From the docker-compose documentation:
Compose supports declaring default environment variables in an environment file named .env placed in the folder where the ‘docker-compose’ command is executed (current working directory). Reference (https://docs.docker.com/compose/gettingstarted/)
While still within the /helpy/docker folder, run the ‘docker-compose’ command to get your container running:
sudo docker-compose up -d
At this point, your Helpy container is running and you can see it’s status using the list container command as follows:
sudo docker container ls
Lists all running containers
sudo docker container ls -a
Lists all containers, even those not running
Next, stop the services in preparation for a server reboot as follows:
sudo docker-compose stop
Next reboot the Ubuntu droplet as follows:
sudo reboot
You’ll be disconnected from your droplet.
Once you log back onto your droplet using the newly created root user’s password or the ‘helpyadmin’ user, you’ll need to start the Docker container again since you rebooted the droplet. Switch to the ‘helpyadmin’ user if you are not already there. Change current directory to the directory that has the docker-compose file in it which is: /helpy/docker
Start up your containers using:
sudo docker-compose up -d
List the running containers if you want:
sudo docker container ls
There are three containers related to the helpy docker environment.
Now go to your internet browser and enter the ip address of your droplet. You should receive a website with the Helpy pages. Login as the helpy administrator for the first time using the following credentials:
- username/ email address: [email protected]
- password: 12345678
Follow the prompts to create a permanent administrator account using your actual email address and selected password.
Remember to edit Caddyfile if you need automatic SSL. if you want Helpy to connect to your IMAP server, you need to add following just before last line
bundle exec rake helpy:mailman mail_interval=60&