jfusterm / wordpress-ecs

Amazon ECS demo with Wordpress containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wordpress on ECS

Practical example on how to get a Wordpress running under an Amazon ECS Cluster using different technologies.

Technologies

Requirements

To use this example you will need an AWS account and:

Usage

  1. Build the Wordpress container.

Packer will use a base Docker image with Ansible to provision all the applications needed to run a Wordpress. The result will be saved into a container named jfusterm/wp-packer with a version tag 4.4.2.

Note: If you want to change the image tag you have to change it in wp-packer.json and wordpress.json.

# packer build wp-packer.json
  1. Push the container to Dockerhub

Check that the image is ready.

# docker images

REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
jfusterm/wp-packer        4.4.2               60bfb4ef7e9d        3 hours ago         138.2 MB

Then you can push it to Dockerhub.

# docker login
# docker push jfusterm/wp-packer:4.4.2
  1. Deploy all the infrastructure needed on AWS using Terraform.
# terraform apply

Once deployed, Terraform will display the ECS Container Instances public IPs and the ELB URL that will distribute the traffic across the different Wordpress container instances.

The RDS connection parameters will be passed on runtime to the Wordpress containers via environment variables.

  1. Once not needed, we can remove all the AWS infrastructure:
# terraform destroy

Considerations

This example uses a basic and simple approach to get a ready to use Wordpress using different technology. Further modifications will be done to get a fully automated, scalable and high available Wordpress. Some thoughts:

  • Wrap all the steps in a single script: build the container, push the container to Dockerhub or a private registry and finally deploy all the infrastructure on AWS.
  • Automate Wordpress installation when the first instance is launched. Note: Currently the ELB won't work properly due to the health-checks configuration until Wordpress is installed from one of the Worpress instances.
  • Distribute the ECS Container Instances across different availability zones and route the traffic using the ELB among them.
  • Decouple Nginx and PHP-FPM in separate containers so can be scaled independently.
  • Use a shared or distributed storage system to persist Wordpress' data. Examples:
  • Remove the RDS single point of failure. Examples:

About

Amazon ECS demo with Wordpress containers

License:MIT License


Languages

Language:HCL 81.4%Language:Shell 12.5%Language:Nginx 6.1%