Skip to main content

Deploying Without Dependencies

07-29-15 Patrick Simpson

Do you hate having production build dependencies? Patrick will show you how to use Mina and CircleCI to kick them nasty thoughts.

At Sparkbox, we love our development build process. We use Grunt and/or Gulp tasks to build our JavaScript and CSS, as well as, run automated tests. For this to work, it requires a lot of third-party libraries and node packages, all of which are installed on our development machines. However, we only commit source files (scss, coffeescript). The staging and production environments pull down the source files (scss, coffeescript) and need to compile them—which means we require all those same development dependencies on our production and/or staging environments. Ack! This gets pretty complicated with frequent updates, version changes, or new and different environments.

There has to be a better way...

A New Deployment Process: Mina + CircleCI

Instead of keeping all our different servers up-to-date with the latest development tools, we’ve created an open-source gem called mina-circle that allows developers to leverage CircleCI containers, which are well maintained and easily configurable. Using CircleCI as a build server frees us from maintaining servers and dependencies. This makes it easy to have our source files compiled (and our tests run) every time we want to deploy on CircleCI.

To get started, add mina and mina-circle to your Gemfile:

source 'http://rubygems.org'
gem 'mina'
gem 'mina-circle'

Then:

bundle install

Then go to your CircleCI Account Page and create an API token (if you don’t have one already). Create a new file named .mina-circle.yml in your home directory, and add an entry for token:

token: your_circle_ci_token

To deploy, ensure in your project that you’ve set up the usual mina deployment configuration.

Leveraging Circle’s build artifacts, we are able to create a complete archive of the build. In the circle.yml file, we issue the command tar --exclude=“.git node_modules” -czvf ~/artifact_example.tar.gz . which creates an archive of the current build (excluding git and node_modules). 

Here is an example circle.yml file that you’ll need for mina-circle.

Combined with Mina, our deployments are able to locate the build (first obtaining the build number) and download the archive during the “deployment” process. This allows us to bypass the production or staging environment dependency requirement! We then curl down the archive, unpack it, and our site lives on our environment without building the assets.

Using this approach frees up our environment requirements and makes the environment more secure with fewer headaches. No more updating node or waiting for npm to compile assets on our production or staging environments.

Give it a Try

So give it a try and feel free to submit your pull requests and issues to the repository. And one day, it’s on our radar to try this out using Docker containers as our development environments so that we could deploy those containers into production.

Related Content

User-Centered Thinking: 7 Things to Consider and a Free Guide

Want the benefits of UX but not sure where to start? Grab our guide to evaluate your needs, earn buy-in, and get hiring tips.

More Details

See Everything In

Want to talk about how we can work together?

Katie can help

A portrait of Vice President of Business Development, Katie Jennings.

Katie Jennings

Vice President of Business Development