WordPress on Amazon ECS and RDS with Mu
AWS CodePipeline orchestrates the continuous delivery pipeline:
- Watches the rendia-wordpress GitHub repo for changes and automatically applies them shortly after you push.
- AWS CodeBuild uses
buildspec.yml
to run any custom steps you add there. - AWS CodeBuild generates your own Docker image by combining the results of the last step with the official WordPress image and storing it in Amazon ECR.
- Container is deployed to "test" environment, fronted by an Application Load Balancer, and backed by backed by an RDS Aurora database.
- Manually inspect your container and approve or reject it within the CodePipeline UI
- If approved, container is deployed to "prod" environment.
Mu creates the applicable AWS resources are created through AWS CloudFormation using a pair of simple YAML files.
GitHub stores your infrastructural code.
mu acts as your front-end to AWS by generating and applying CloudFront templates, orchestrated by CodePipeline.
The official WordPress Docker container is deployed to Amazon ECS, and your custom copy is stored in Amazon ECR.
An ECS cluster is run for each environment we define, "test" and "prod".
An AWS ALB sits in front of each cluster.
Your WordPress database will be provided by an Amazon RDS cluster, one for each environment. Each runs Aurora, Amazon's highly optimized clone of MySQL.
git clone rendia-wordpress
cd rendia-wordpress
./run-docker-local
Everything in repo's html
directory will be installed in the containers. Add files there and they'll end up in /var/www/html
, right alongside WordPress. Want to install persistent plugins? Put them in html/wp-content/plugins
. Want to install a theme? Add it to html/wp-content/themes
.
When developing wordpress with docker locally, go to localhost:8000
to view site in browser.
Commit your changes and push them back up to Github:
git add mu.yml
git commit -m'first update' && git push
CodePipeline watches repo for changes. Just push your code to trigger updates in your WordPress deployment.
Mu manages the database passwords, they can be read them from Amazon's SSM ParameterStore:
aws ssm get-parameters --names mu-database-mu-wordpress-test-DatabaseMasterPassword --with-decryption
aws ssm get-parameters --names mu-database-mu-wordpress-prod-DatabaseMasterPassword --with-decryption
Pipeline is configured to only deploy from master branch of org's repo. I recommend creating a fork of org's repo and cloning to local for development.