If there was a piece of interwebs kit I would like to buy flowers, it would without doubt be Amazon’s Elastic Beanstalk with autoscaling.. Couple it with the Lucee scripting language and I’d happily take it home to meet my parents..
After much experimentation and many iterations (failed attempts and hair-pulling), I’ve managed to deploy Lucee applications (with my fave framework.. CFWheels) to the AWS Elastic Beanstalk platform and have it running reliably in production for a number of months.
My setup is a bit more complex than described below, but hopefully these bare bones will get you started on the path to automated utopia.. Those bare bones will result in a finished .war file that you can upload to EB using their deploy by file upload feature. You could also use the AWS command line tools, AWS toolkit for Eclipse, a Jenkins plugin or one of the many SaaS deployment platforms around.
I personally use Jenkins (on an AWS EC2 instance) to pull, build, test and deploy. I prefer this type of setup as there is much less margin for human error, and the resulting 60Mb+ war file is transferred within your Virtual Private Cloud rather than travelling across the interwebs if you were to manually upload it for every deployment.. oh, and it’s open source.
At a high level, I will outline how to download the Lucee server war file, combine your application’s code, and use some AWS sorcery to configure your Lucee application. There are some pre-requisites:
- The settings that you would normally configure in Lucee admin, should be in Application.cfc (See the Export feature in Lucee admin)
- The commands to create the finished war file are written for Linux (If you’re Windows inclined , you could either ‘translate’ them to Windows commands, try Cygwin or a Virtual Machine)
- You’ll need a src/ directory in your application containing the files outlined below
- An AWS account with an empty Tomcat 8 Elastic Beanstalk environment
In a nutshell, what happens is the Lucee jars, your code and some config files are all copied to the “build” directory, then zipped into a sexy war file ready for upload/deploy to the Elastic Beanstalk environment.
These are configuration files.. for a production application, you’ll need to provide your own lucee-server.xml and most likely your own rewrite rules in urlrewrite.xml. If you don’t need url rewriting, then remove all reference to them. The .ebextensions execute EB container commands.. the one provided simply copies your lucee-server.xml file into place. To create your finished war file,
cd to your application’s root directory then run these commands. I’d suggest creating a shell script.. and if you feel adventurous, allow an ‘environment’ option that will create different environment builds for your application’s deployment pipeline
This should give you a production ready war file located at: build/app-production-master.war. Now you can manually upload your app-production-master.war and be on your way..
Some of my recommendations:
- Build in the cloud using Jenkins (or your choice of CI server)
- Host the Lucee war file in your own S3 bucket.. you’re less at the mercy of 3rd parties connectivity issues.
- You can easily incorporate additional jar files as per the tuckey rewrite tool.. just copy them into
Any suggestions, improvements & feedback welcome.
Many thanks for that. How do you run the environment locally for development?
It’s just a plain old Lucee/Tomcat install. We push changes to Github which Jenkins polls, then does the builds for CI, staging and production. It works well for us as our team develops on different operating systems.. so having Jenkins handle all the tricky stuff on Linux in the cloud works nicely.
Would be nice if we could get a local tool chain going with something like CommandBox 2.0 — unfortunately, it doesn’t much like you running your own WEB-INF folder at the moment.
For simple apps, the `eb deploy` command line, with different branches bound to different environments is very appealing.
Yes, I’m looking into having Jenkins run CommandBox to do the builds.. it would be much more fun to have written that script in cfml rather than bash!
I was surfing the web for AWS and I saw your Blog. I read a few of your posts and think they were awesome. Thank you.