Code Monkey home page Code Monkey logo

wordpress-ecs's Introduction

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:

wordpress-ecs's People

Contributors

jfusterm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wordpress-ecs's Issues

Errors on build on OS X Docker 1.13.1 Stable when using packer build wp-packer.json

docker: fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "Unexpected error when accessing exploded file: [Errno 2] No such file or directory: '/usr/share/nginx/html/wordpress'"}
docker:
docker: NO MORE HOSTS LEFT *************************************************************
docker: to retry, use: --limit @/tmp/packer-provisioner-ansible-local/wordpress.retry
docker:
docker: PLAY RECAP *********************************************************************
docker: 127.0.0.1                  : ok=9    changed=8    unreachable=0    failed=1
docker:

==> docker: Killing the container: 7dd73dd45a4f611197c6ae12cc3f8f7b43303fe07ffa1c59fba34f8921792e6f
Build 'docker' errored: Error executing Ansible: Non-zero exit status: 2

==> Some builds didn't complete successfully and had errors:
--> docker: Error executing Ansible: Non-zero exit status: 2

==> Builds finished but no artifacts were created.

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.