Danny Denenberg

   Blog    About    Projects

How to create a Ghost blog with docker+AWS

  1. Login to the AWS website
  2. Click on Services (top bar)
  3. Click on EC2
  4. Click on Launch Instance
  5. Search and choose Ubuntu Server (18 or up)
  6. Leave selected the free tear (unless you have upwards of $10000000000)
  7. Edit security groups (by clicking on edit security groups)
  8. Click Add rule - http - leave other defaults
  9. Click Add rule - https -leave other defaults
  10. Click Launch Instance
  11. Choose Create new pair key from the drop down selector (name it and download it)
  12. Open terminal
  13. CD into the directory where the pair key was downloaded to and do this
  14. Change the .pem file permissions with: sudo chmod 600 <<MYPAIRKEYFILENAME>>.pem
  15. Go to your AWS instances tab in the EC2 page and find the Public DNS (IPv4) of your instance
  16. ssh [email protected]<<INSERT.Public.Dns.IPv4>> -i PairKeyName.pem
  17. Type yes to get into the ubuntu computer
  18. Install docker: sudo snap install docker
  19. Make a start file: vim startserver
  20. Put this in the script👇:
  21. #!/bin/bash; docker run -d --name website -e url=https://<<websitename>> -p 80:2386 -v /home/ubuntu/website:/var/lib/ghost/content ghost
  22. Create a /website directory: mkdir website
  23. Go to cloudflare.com and link your website to it by creating an account (or signing in) and going through the steps to link it to your URL that you used in step 21
  24. Make a CNAME record with the name being @ and the address being the public IPv4 of the aws instance that you found in step 15 (example: ec2-54-224-132-93.compute-1.amazonaws.com)
  25. Go to your domain service (mine is google domains) and set the nameservers to be cloudflare’s (you should have already done this step while setting up cloudflare in step 23)
  26. Change the permissions of the startserver script to be able to execute: chmod +x startscript
  27. Now run it: ./startscript
  28. It will take a bit to complete because docker needs to pull the image off of their website, but when it does everything should be up and running

Please Note

It may take a bit for cloudflare to enable https. It will also take some time for your domain provider to change its nameservers and for that change to propagate back to cloudflare.


Questions?

Have a question about this post, js, GitHub, or anything else? Ask away on my AMA repo or by 🔫-ing me an email.