The Holy Grail WordPress project template for Heroku deployment and local Docker development.
- Bedrock-like modern development environment
- Local Heroku-like environment with Docker-compose
- WP-CLI
- Configurable Nginx
- Travis CI pipeline you can run with Docker
- PHP Codesniffer with nicer coding standards for WordPress
- Terraform deployment for full WordPress stack provisioning to Heroku & AWS
- Heroku PHP7 & Node 8 application runtime
- Heroku Redis Cache
- AWS S3 for media uploads
- AWS RDS for MariaDB
- Papertrail log management
- NPM scripts for ease of use
Install Docker
Install Node.js
Install AWS-CLI
Install Heroku-CLI
Clone this repo and source set up your environment inside the project root.
cp .env.sample .env
source .env
I also recommend installing autoenv, so you don't have to run the source command all the time.
Start a shell inside Docker. It might take a moment for the images to download and build. This is normal.
npm run shell
Now you can run composer install
inside Docker
composer install && exit
Outside the docker shell, you can now start the main process
npm start
You can now navigate to http://localhost:8080
to
start working with your local WordPress installation.
To deploy using Terraform, make sure you've prepared Heroku and AWS credentials, and you've installed the Terraform CLI binary on your system.
You can get your Heroku API key from the Heroku dashboard
export HEROKU_API_KEY=
export HEROKU_EMAIL=
For AWS, create an IAM user with Administrator rights
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
The state of Terraform is managed in S3, so it should automatically sync any
changes from the remote backend. For this you'll need to manually set up an S3
bucket in the eu-west-1 region with the name wp-terraform-backend
terraform init
terraform apply
After this you can push to your newly created Heroku app's git URL to trigger a Heroku deployment.
git remote add dev https://git.heroku.com/[my-project-name]-dev.git
git push dev
You can run WP-CLI locally by starting the shell container
npm run shell
To run wp-cli in a Heroku instance, just run a temporary dyno.
heroku run bash
Both environments have WP-CLI available as wp
.
Travis CI will run the ci
container to test your app. You can do the same
locally:
npm test