Skip to content
WordPress project template for Heroku and local Docker
Branch: master
Clone or download
anttiviljami Merge pull request #15 from k1sul1/patch-1
Make MySQL persistent again
Latest commit b422559 Mar 26, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Add --allow-root for wp-cli May 14, 2017
config Fix linter issues Jan 26, 2019
htdocs Remove phpinfo Oct 29, 2017
tools Use local mysqldump instead of heroku one Jan 26, 2019
.env.sample
.env.test.sample Get rid of unnecessary resolve-env script Oct 28, 2017
.gitignore Terraform configuration Oct 28, 2017
.travis.yml Remove composer cache from travis Aug 16, 2018
Dockerfile Update Dockerfile Jan 26, 2019
LICENSE Initial version May 14, 2017
Procfile Add docker configuration May 14, 2017
README.md Remove video from README Jan 26, 2019
composer.json
composer.lock Update to WP-CLI 2, update packages Jan 26, 2019
docker-compose.yml Make MySQL persistent again Mar 25, 2019
package-lock.json Added new ubuntu url's Jan 25, 2018
package.json Install wpcs as a composer dependency Aug 16, 2018
phpcs.xml Fix linter issues Jan 26, 2019
terraform-dev.tf Make S3 uploads bucket public by default Feb 8, 2018
terraform.tf Split Terraform config to main file and dev instance Feb 8, 2018
wp-cli.yml Initial version May 14, 2017

README.md

WP Heroku Docker Project

Build Status License

The Holy Grail WordPress project template for Heroku deployment and local Docker development.

Features

  • 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

Local Development

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.

Deploying with Terraform

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

WP-CLI

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.

Running tests

Travis CI will run the ci container to test your app. You can do the same locally:

npm test
You can’t perform that action at this time.