It was great to get a glimpse at Amazon Elastic Beanstalk + Docker, presented by Markku Lepisto, AWS Principal technologist at DrupalCamp Manila 2014 last month.
Elastic Beanstalk has been getting popular for deploying and managing applications in the AWS cloud. Once your application is up in the cloud, Elastic Beanstalk will provision, monitor, and scale capacity, and you also have the option to load balance all incoming requests across all your instances.
What interested me most is Docker Integration with AWS Beanstalk in a Drupal environment.
Deployment and Automation
Most developers right now are excited for automated deployments. Knowing how to create instances from a wide variety of hypervisors (e.g. VirtualBox, VMware or Vagrant) was a milestone for developers.
It was also a breakthrough in a conflict between developers and operations, where projects were being compromised because it takes a long time to provision servers and set up environments, thus developers waste time waiting for a server to get up and running before they can start deploying their apps on those servers.
AWS Beanstalk and Docker
Seven months ago, Docker was a rather unknown project. It wasn’t until recently that a massive number of developers started to contribute to the project because Docker simplified and rocketed their development workflow and efficiency.
Packaging applications as Docker images makes them portable, reliable, easy to share with others and simple to test.
Now, developers with AWS accounts can take advantage of features like EC2, RDS (including fully-managed MySQL, PostgreSQL, Oracle, and SQL Server databases), and IAM.
AWS Beanstalk and Docker Meets Drupal
25% of the US government’s sites are using Drupal as their platform, from publishing to Open Data Applications, and some media giants like CNN and Al Jazeera are already in engaged on this platform. This is just one of the reasons why Drupal is one of the most reliable content management framework out there.
A couple of weeks ago, X-Team launched our Alpha version of drush_deployment module, an extended feature of Drush (the “swiss army knife of Drupal”). Drush is a shell-based tool you can use in the console to automate Drupal, from setting up a site or simply adding a user, downloading and enabling modules, or migrating content and a lot more.
Our Drush Deployment module is using a gitElephant Library for git (a community-driven project on GitHub that is heavily used in symfony projects).
These are some of its features:
All commands in drush_deployment: (drush_deployment)
- check-repo (dm-check) – Check the target directory is a valid git repository.
- clone-repo (dm-cr) – Clone a repository.
- deploy-updates – Deploy all the changes.
- deployment-config (dm-conf) – Return an array of configuration.
- git-init (dm-gi) – Initialize git in target directory.
- latest-tag (dm-lt) – Get the latest tag.
- list-branches (dm-lsb) – List all branches.
- list-tags (dm-lts) – List all tags.
- maintenance (dm-m) – Manage site maintenance page.
- rebuild-cache (dm-rc) – Rebuild Cache
- release-tag (dm-rt, dm-dtag) – Checkout/deploy a tag.
- tag-notes (tn, tagnotes) – Generate release notes using all commits between two tags
We next wanted to integrate our deployment module with AWS Beanstalk Docker.
After days of experimenting and testing we have come up with this docker image on github: https://github.com/fusionx1/aws-docker-drupal-deployment
Steps on how to deploy Drupal using drush_deployment on AWS Beanstalk Docker
- Zip contents cloned from the repository.
- Login to your AWS Account
- Navigate to Elastic Beanstalk.
- Create a new application, and select Docker predefined configurations and hit the Next button.
- Set your Environment URL, a personalized and temporary URL
- Upload your zipped file make sure your Docker file is inside it.
- You may use RDS if you want to have a separately running Database ranging from Mysql, MSQL, or Oracle.
- Set your instance type, each instance has corresponding specs.
- Set your preconfigured SSH Public Key and email address.
- Set your environment tags.
- Finally, hit the Launch button to start the deployment process.
- Deployment usually takes 15-20 minutes.
- Voila! We now have a Drupal site with an AWS architecture that can handle hundreds of thousands of users.