AWS - Docker Ghost - MySQL configuration

You're live! Yes, after the massive update with AWS-Docker-Ghost configuration. Nice.

Getting Started

The main idea was to update the blog, using the following technologies:

In order to accomplish this simple task, I'm putting here all the required steps. Overall, it's quite simple but I couldn't find a single website where I could follow sequentially all these steps.

Overview

  1. Registration
  2. Configuration
  3. Publish
  4. Customization
  5. BackUp, tags and releases

Registration

  • Domain

I registered this domain in nic.com , nevertheless you have plenty of options (free and paid).

  • Amazon Web Services Registration

Access to Amazon WebServices. Create an account if you don't have it or use the existing one by now, the first year it's free. It will require a credit car, but they won't charge you.

  • Docker

This is an optional step, as you can have your own repository in github, bitbucket or many others. Docker Hub allows you to have 1 private repository where you can put your docker image once that it's done.

Create an account in Docker Hub

Configuration

The whole concept is to register a domain and point the DNS to your own server, in this case Amazon Web Service.

  • Amazon WebServices

  • Create an instance. For my case, I'm using the smallest (and the cheapest one): t2.nano with Linux configuration. You can pick many other servers and setup the configuration you consider better. You can find the prices and specs here.

  • Create a Security group and open only port 80 (everywhere) and port 22 only for you local machine (this will allow you to ssh the server using your generated key).

  • Create a new registry under Route53 inside Amazon Console and add your domain name with the DNS that provides nic.com

  • Create a certificate in order to access to the console via ssh. Actually I found this steps is automatically done in the creation of the EC2 instance. If not, go to Certificate Manager section. [PEM_KEY]

  • Domain

Access to nic.com and edit the DNS with the ones that AWS provides. You can find them under Route53 with the following format:

NS-XXXX.AWSDNS-XX.ORG
NS-XXX.AWSDNS-XX.NET
NS-XXX.AWSDNS-XX.COM
NS-XXXX.AWSDNS-XX.CO.UK

  • Docker

Now we can access to AWS console via terminal.

  • Open your terminal and change the your local pem file permission:
chmod 600 [LOCAL_PATH]/[PEM_KEY]  
  • Connect to the AWS
ssh -i [LOCAL_PATH]/[PEM_KEY]  ec2-user@[YOUR_HOST]  
  • Update yum on the server
sudo yum update -y  
  • Install docker
 sudo yum install -y docker
  • Start docker
sudo service docker start  
  • Grant permission to docker user (later you can create your own user and modify this step)
sudo usermod -a -G docker ec2-user  
  • Check docker installation
docker info  
  • Clone mysql-ghost template
git clone https://github.com/jmazzetti/docker-ghost-mysql-template  
  • Clone MYSQL docker container. I'm adding the current tag I'm using, but you can clone it with latest if you want.
docker pull mysql:5.7.15  

-- Run MYSQL docker:

docker run --name mysql -e MYSQL_ROOT_PASSWORD=[YOUR_PSW] -d mysql:5.7.15  
  • Clone GHOST docker container:
docker pull ghost  
  • Configure docker-compose file
vi docker-compose.yml  
  • Install the composer engine:
sudo yum install docker-engine  
  • Start docker service:
sudo service docker start  

Publish

With the following commands, we are building the docker-compose. Inside we have a MYSQL and GHOST images.

  • Run the composer:
docker-compose build  
  • Run the blog in production:
docker-compose up -d  

Customization

If you want to change the original Casper look and feel, you can copy your theme under:

/docker-ghost-template/ghost/volumes/content/themes

BackUp, tags and releases

  • Run on terminal your docker tag: [IMAGEID] [DOCKERHUBUSER]/[REPO_NAME]:[TAG]
docker tag 4a1258d177ca jmazzetti/blog:1.0  
  • login to your Docker Repository
docker login  
  • Push your tag to your docker depository [REPO_NAME]:[TAG]
docker push jmazzetti/blog:1.0