Giter VIP home page Giter VIP logo

ghost-blog-in-aws's Introduction

Deploy Ghost blog in AWS using CloudFormation

Ghost is a lightweight blogging platform. This repository contains CloudFormation scripts and other resources to deploy your own Ghost blog stack in AWS. This is NOT designed to be production ready but to host a personal blog with minimal cost using AWS free tier :-)

The stack runs 4 docker containers inside an EC2 instance.

  1. Ghost - blogging platform
  2. Traefik - reverse proxy
  3. Commento - commenting platform
  4. PostgreSQL - commento database

Docker-compose is used for the container orchestration.

Below is the high level design.

blog-design

Prerequisites

  1. Registered domain for the Lets Encrypt integration to work
  2. User account and domain verification with an SMTP provider such as mailgun
  3. AWS account and an IAM user with programmatic access

Configuration files to update before deployment

Once you clone the repository make sure to update the following files to reflect your details.

  1. commento.env

    Comment out everything but below two values for the initial deployment as smtp setup interferes with the Commento admin account registration

    • COMMENTO_ORIGIN

    • COMMENTO_POSTGRES

  2. ghost.env - add your smtp details here

  3. docker-compose.yaml

    Update the following lines

    • certificatesresolvers.letsencrypt.acme.email={YOUR EMAIL}
    • traefik.http.routers.ghost.rule=Host({YOUR DOMAIN})
    • traefik.http.routers.commento.rule=Host(commento.{YOUR DOMAIN})
  4. ghost-blog-setup.cfn.yaml

    • command: "sudo aws s3 cp s3://{YOUR BUCKET NAME}/blog/config/ /data/traefik/ --recursive"
  5. inception.cfn.yaml

    • Update HostedZone with your domain
    • Update MyMailGunDomainKeyRecordSet resource with your domain key
  6. Makefile

    • Update REGION, PROFILE and BUCKET values

Initial deployment

  1. Deploy the inception stack - this creates the initial infrastructure in the AWS account
    • make create-inception-stack STACK_NAME=inception-stack-name
  2. Deploy the blog-host stack - this deployes and configures the Ghost host
    • make create-blog-host-stack STACK_NAME=host-stack-name

Check CloudFormation stacks for any errors.

After deployment

  1. Use AWS SSM to log into the Ghost host, navigate to /data/traefik folder and bring up the stack with docker-compose up -d
  2. Register your admin user with ghost on https://yourdomain.com/ghost
  3. Register yourself to the local commento on https://commento.yourdomain.com
  4. Use AWS SSM to log into the Ghost host, navigate to /data/traefik folder and bring down the stack with docker-compose down
  5. Uncomment smtp setup values in commento.env
  6. Uncomment COMMENTO_FORBID_NEW_OWNERS=true to avoid new registered users
  7. Bring up the stack again with docker-compose up -d

How to backup the blog configs and content

  1. In the Ghost host: cd /data/traefik
  2. Set BUCKET value in backup-all.sh
  3. ./backup-all.sh

This will backup all the content and config files into the S3.

How to update all the components

  1. In the Ghost host: cd /data/traefik
  2. Set BUCKET value in update-components.sh
  3. ./update-components.sh

This will pull new docker images and update the stack.

Further info

Have a look at my blog https://fewmorewords.com/ghost-on-aws

It is deployed using this stack and only costs me less than a dollar per month :-) with AWS free tier

Reference

  1. https://ghost.org/
  2. https://containo.us/traefik/
  3. https://commento.io/

Enjoy!

ghost-blog-in-aws's People

Contributors

jayanath avatar requix avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

requix

ghost-blog-in-aws's Issues

Update backup script to zip content before upload to S3

Current update script simply copy everything as single putObject action which consumes the free putObject limit quickly. We should zip the backup content before push it to S3 so that each backup cycle will consume only one putObject action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.