Bedrock on aws ElastickBeanstalk multi containers Docker
Bedrock is a modern WordPress stack that helps you get started with the best development tools and project structure.
Much of the philosophy behind Bedrock is inspired by the Twelve-Factor App methodology including the WordPress specific version.
- Better folder structure (adding site/ folder to separate php application from deployment configurations)
- Dependency management with Composer
- Easy WordPress configuration with environment specific files
- Environment variables with Dotenv
- Autoloader for mu-plugins (use regular plugins as mu-plugins)
- Enhanced security (separated web root and secure passwords with wp-password-bcrypt)
See a complete working example in the roots-example-project.com repo.
- PHP >= 5.6
- Composer - Install
- Aws account
- Configured pipeline with:
- CodeCommit.
- CodeBuild on a docker environment can run composer.
- Elastic Container Service with good php-fpm image - to run composer and php-fpm on.
- Elastic Beanstalk on a multi docker environment.
- Create a new project in a new folder for your project:
composer create-project roots/bedrock your-project-folder-name
- Update environment variables in
.envfile - mostly for local development:
RDS_DB_NAME- Database nameRDS_USERNAME- Database userRDS_PASSWORD- Database passwordRDS_HOSTNAME- Database hostWP_ENV- Set to environment (development,staging,production)WP_HOME- Full URL to WordPress home (http://example.com)WP_SITEURL- Full URL to WordPress including subdirectory (http://example.com/wp)AUTH_KEY,SECURE_AUTH_KEY,LOGGED_IN_KEY,NONCE_KEY,AUTH_SALT,SECURE_AUTH_SALT,LOGGED_IN_SALT,NONCE_SALT
If you want to automatically generate the security keys (assuming you have wp-cli installed locally) you can use the very handy wp-cli-dotenv-command:
wp package install aaemnnosttv/wp-cli-dotenv-command
wp dotenv salts regenerate
Or, you can cut and paste from the Roots WordPress Salt Generator.
On ElasticBeanstalk multi containers environment, env vars are transferd throgh RDS data tier and custome env vars you can insert on ebstalk->environment->config->softwer configurations. so on this version of bedrock - the env vars are ElasticBeanstalk multi containers Ready
-
Add theme(s) in
web/app/themesas you would for a normal WordPress site. -
Set your site vhost document root to
/path/to/site/web/(/path/to/site/current/web/if using deploys) -
Access WP admin at
http://example.com/wp/wp-admin
- selecting codeCommit as a source (or any other source supported and available).
- running codeBuild with buildspec.yml - IMPORTANT! configure codeBuild to run on a php-fpm image with composer install on it.
- configure ElasticBeanstalk to use multi containers docker environment - IMPORTANT! change Dockerrunaws.json file with the right docker image details, should look something like this: 123456789101.dkr.ecr.eu-wast-1.amazonaws.com/php-fpm:latest
- push code to codeCommit to start deployment process.
- codeBuild install all composer dependencies and create artifact that include all files necessary to run the software.
- ElasticBeanstalk deploys all those files into a host.
- php-fpm docker copy all site files and run php-fpm.
- nginx docker copy all site and config files and run nginx so it can serve all existing files.
amazon web services wp plugin is required by default by composer.json, it's critical to configure it. it's recommended to serve files with aws cloudFront, but also possible with simple aws S3 with hosting permission.
Bedrock documentation is available at https://roots.io/bedrock/docs/.
BeanStalk multi containers docker documentation is available at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html.
Contributions are welcome from everyone. We have contributing guidelines to help you get started.
Keep track of development and community news.
- Participate on the Roots Discourse
- Follow @rootswp on Twitter
- Read and subscribe to the Roots Blog
- Subscribe to the Roots Newsletter
- Listen to the Roots Radio podcast